Function Contracts for Retried Operations
A retry contract identifies whether repeating a call after a partial failure can duplicate an effect.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Use a concrete write
Setting document 17 to archived can leave it archived if the first attempt succeeded but its response was lost. Appending a new audit line on each call can create duplicates. Idempotent state transitions describe why these promises differ.
Try the ambiguous result
Simulate a failure after the write, then call again using the same request identity. Verify both the stored state and the number of observable records. A bounded retry loop can govern attempts once the contract identifies which failures are temporary.[1][2]
Sketch success that the caller never receives
A client asks a service to create export job Q7. The service saves the job, then the connection closes before its reply arrives. From the client side this looks like failure. If a repeated call creates a fresh job it can produce two exports. Under an idempotency contract, the service remembers the first result for a stable request identifier and returns it on a repeat. Concurrency matters because two in-flight calls can otherwise both create the job. See idempotent state transitions.
Classify failures with an observable test
An invalid date range is a predictable input error. Retrying the same range adds load without resolving it. A test double can produce a temporary timeout and then success, or simulate a persisted result followed by a lost reply. In the second case verify the job count, the repeated identifier, and the returned job identity. Use a maximum elapsed time or an attempt budget so failure is observable and bounded. See retry budgets for loops to trace the scheduling.