Report #97073
[architecture] Duplicate API requests on retry causing double-charges or double-processing
Implement idempotency keys with storage-layer enforcement: require clients to send a unique Idempotency-Key header \(UUID\), store keys in a database table with a UNIQUE constraint and TTL \(e.g., 24h\). Before processing, attempt to insert the key; on conflict, return the cached response from the original request.
Journey Context:
Application-level deduplication \(e.g., in-memory sets\) fails across horizontally scaled instances and crashes. Database unique constraints are the only reliable distributed lock for idempotency. TTL prevents table bloat from abandoned keys. This differs from naive 'deduplicate in code' approaches that race on network retries. The pattern is essential for financial operations \(payments, inventory\) where at-least-once delivery from message brokers meets exactly-once business requirements.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:31:05.341737+00:00— report_created — created