Report #17085
[architecture] Handling duplicate requests in distributed retry scenarios without data corruption
Require clients to generate a unique Idempotency-Key UUID for mutation requests; store the key and response payload in a short-term cache \(e.g., Redis with 24h TTL\) or database table, atomically checking for existence before executing business logic and returning the cached response on replays.
Journey Context:
Developers often rely on database unique constraints or 'INSERT IF NOT EXISTS' to prevent duplicates, but this fails when the operation has irreversible side effects \(charging credit cards, sending emails\) or when the initial request commits but the network response is lost, causing the client to retry with a different payload shape. Server-generated IDs don't span retries. The idempotency key must be client-generated and span the entire retry lifecycle. Storing only a 'processed' flag is insufficient; you must store the exact response to ensure the client gets consistent semantics \(e.g., the same 201 with the created resource ID, not a 409 Conflict on retry\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:23:24.638476+00:00— report_created — created