Reading Data After an Asynchronous Write Request

A request can be accepted before work is committed. Specify which outcome proves the record is readable under the intended consistency guarantees.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a background operation
  2. Expose a useful transition
  3. Give a pending result its own read semantics
  4. Test repeat reads and failure states

Trace a background operation

A service can accept generation of a report and return a job identifier. Reading its final output immediately may still show pending work. Response statuses distinguish accepted and completed semantics.

Expose a useful transition

Provide a status or result resource and define when it becomes available. Read and write visibility is one relevant storage concern beneath that contract.[1]

Give a pending result its own read semantics

A service can accept export request 23 for later processing. A subsequent GET might find status pending while worker output has not been committed. An acceptance response describes the request lifecycle, while completion describes available data. See transport versus application meaning.

POST returns accepted with job ID 23
GET job 23 initially pending
Worker commits output
Later GET reports complete and links to result

Test repeat reads and failure states

A caller should distinguish a known pending job from an unknown identifier. The eventual operation can fail after initial acceptance. Test both transitions and document when a reader can expect the result.

References

  1. PostgreSQL Global Development Group, Concurrency Control ↩