Report #8845
[architecture] Idempotency keys for exactly-once processing in distributed payments
Require clients to generate a UUID idempotency key for all non-idempotent mutations; server stores the key with the response for a TTL \(e.g., 24h\) and returns the cached response for replays without re-executing.
Journey Context:
Network timeouts inevitably cause clients to retry, leading to double charges or duplicate resource creation. 'Exactly-once delivery' is impossible in distributed systems; the fix is making operations idempotent via client-generated keys. The client must create a unique key \(UUID v4\) and send it in a header \(e.g., Idempotency-Key\). The server persists this key in a lookup table \(Redis or Postgres\) alongside the response payload and a TTL. If the same key arrives again, the server returns the stored response without touching business logic. Common failures: making the key optional, letting the server generate it \(breaks retries across client restarts\), or using in-memory storage only \(server restarts lose track\). Also ensure the storage is as durable as the main transaction or use a two-phase commit pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:40:14.355604+00:00— report_created — created