An idempotency key protects an operation for as long as the receiver recognizes it, under the receiver’s actual contract. Use this 90-minute workshop to discover what your retry queue does when an old operation returns after the receiver’s record is gone.

The exercise needs a fake clock, a caller ledger, and a disposable receiver that can remember an operation key and its result for a configurable period. Count requests received and effects committed separately. The suggested times below are for facilitation, not a benchmark.

0–20 minutes: draw the clocks

Choose one write with a visible result, such as adding a note to a synthetic ticket. Draw four times: original intent, first send, receiver retention expiry, and oldest possible replay. Include worker restarts, delayed queues and manually resumed jobs. Name the owner of each clock. If a provider publishes only a minimum retention time, use the guaranteed bound with a safety margin; do not assume a key is usable because it worked yesterday.

20–50 minutes: predict the ledger

Give one operation a stable, unique ID and freeze its payload. Give a second deliberate operation with the same payload its own ID. Have the receiver store both its first receipt and a digest of the parameters associated with the key. Pick ten minutes as the artificial fixture’s retention period.

  • At minute zero, deliver the first request. Keep the effect at the receiver but suppress the response.
  • At minute two, replay the original ID with identical parameters. Predict two deliveries, one effect and the original receipt.
  • Before expiry, submit the original ID with different parameters. The fake receiver should reject that mismatch. A changed business intention needs its own decision.
  • At minute eleven, expire the fixture’s record. Before delivering anything, ask whether the caller can establish what happened to the original operation. Resending to this fixture will create a new effect. A locally retained key alone cannot prevent that.

50–75 minutes: decide how to recover

Assign one participant to the caller, one to the receiver and one to review. Offer an authoritative lookup tied to the original operation. If it identifies a committed effect, record its ID. Then remove that lookup and replay the discussion. When the original result is still uncertain and the deduplication window has expired, mark the operation unresolved for reconciliation.

75–90 minutes: compare with the real contract

Write down one API’s key scope, retention guarantee, parameter-mismatch behavior, documented replay response and a maximum automatic retry age. For example, Stripe API v1 documents that pruning becomes possible once a key is at least 24 hours old. The workshop’s ten-minute window belongs only to the fixture. Stripe API idempotency

Leave with two measurements for each exercise: attempts received and distinct committed effect IDs. A second delivery and a second effect call for different fixes.

Test a delayed delivery at the retention boundary

Record the receiver’s unique effect IDs at minute zero and after the duplicate delivery at minute two. Then move the fake clock beyond its ten-minute retention and resume the caller from its saved operation. The safe caller should reconcile the old operation or surface it as unresolved instead of making an automatic new write. Verify both the receiver’s request counter and effect counter. A zero duplicate-effect count means little if the caller silently dropped every request.

This article was created with AI assistance.