Report #13265
[architecture] How to ensure payment endpoint processes request exactly once despite network retries
Require clients to send a unique Idempotency-Key header \(UUID v4\) for mutating requests; server stores the key and response payload atomically in a lookup table \(Redis/DB with 24h TTL\) before executing business logic; if key exists, return the stored response without re-executing.
Journey Context:
Network failures make 'exactly-once' delivery impossible at the transport layer; systems must be 'idempotent' \(multiple identical requests have the same effect as one\). The idempotency key pattern shifts the responsibility to the client to generate a unique identifier spanning retries. The critical implementation detail is atomic 'check-then-act': the server must verify key existence and store a placeholder in a single atomic operation to prevent race conditions where two identical requests slip through. The response must be cached and replayed for duplicates to ensure the client sees consistent state \(e.g., the same charge ID\). Common failures: using request body hash as the key \(fails if timestamps differ between retries\), server-generated keys \(unusable for retries where original response was lost\), or neglecting TTL causing unbounded storage growth.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:16:37.234932+00:00— report_created — created