What Idempotency Actually Means
coreadvancedAn idempotent operation can be retransmitted or retried with no additional side effects. Running it twice leaves the system in the same state as running it once, and the caller gets the same answer either way. That property is what makes retries safe — and without it, every timeout becomes a choice between losing work and duplicating it.
Think of it as
The problem is not the retry; it is the ambiguous timeout. When a caller does not get a response, it cannot tell whether the operation succeeded, failed, or is still running. Idempotency removes the need to know: retrying is correct in all three cases.
What we're doing: Make a create endpoint safe to retry, and see what "semantically equivalent response" requires.
- 1
- Client-generated is the whole point, and it is the detail most often reversed.
- 8
- The uniqueness constraint on the key is what makes two concurrent retries race safely — one insert wins.
- 15
- Returning the stored response, not a fresh one, is what "semantically equivalent" means in practice.
- 21
- AWS calls this out directly: request history must be kept beyond the lifetime of the resource.
Why this works: Idempotency is usually described as "do not do it twice", which understates it. The operation also has to answer the second caller correctly, atomically, and long after the resource may have gone. Those three requirements — stored response, single transaction, retention beyond resource lifetime — are what separate a real implementation from one that works only in testing.
Checking for an existing record before writing, in two steps
Wrong
Better
What you see: Two retries arriving milliseconds apart both pass the existence check, and both create an order — the exact failure the key was added to prevent.
Why: Check-then-act is not atomic, so two concurrent callers can both observe "not present" before either writes. AWS states the requirement precisely: recording the token and the mutating operations must together meet the ACID properties. A conditional write or a unique constraint pushes that guarantee into the storage layer, where it actually holds.
- A diagram showing one client request that times out, branching into three possible realities.
- The client sends a request and receives no response. From the client's side, all three of the following look identical.
- Reality one: the request never arrived. Retrying is necessary.
- Reality two: the request arrived and succeeded, but the response was lost. Retrying would duplicate the effect — unless the operation is idempotent.
- Reality three: the request arrived and is still running. Retrying may run it twice concurrently.
- Below, the conclusion: without idempotency the client must choose between losing work and duplicating it; with idempotency, retrying is correct in all three realities.
Where the ambiguous timeout shows up
Together
Remember: An idempotent operation can be retried with no additional side effects, because the client cannot tell a lost response from a lost request. Take a client-supplied key, record it and perform the mutation in one atomic transaction, return the same stored response to every retry, and keep the record longer than the resource itself lives.
See also: idempotency mechanisms on aws · never assume exactly once · at least once delivery and duplicate handling · retries and idempotency

