Report #24740
[architecture] How to prevent duplicate processing when a client retries a request due to network timeout
Require clients to generate a unique Idempotency-Key header \(UUID v4\) for mutation requests; the server stores the key with the response payload for a TTL \(e.g., 24h\) and returns the cached response on replay without re-executing business logic.
Journey Context:
Developers often try to use database unique constraints on business fields to prevent duplicates, but this fails for create-then-update flows or when business data legitimately changes between retries. Others try distributed locks \(Redis/Redlock\), but these expire and don't survive process restarts or crashes, leading to split-brain scenarios. Idempotency keys separate the operation's identity from the business state, survive server crashes \(if persisted to disk\), and enable safe client retries without complex coordination. The tradeoff is requiring storage \(Postgres/Redis\) for the key-to-response mapping and forcing clients to generate UUIDs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:56:19.499843+00:00— report_created — created