Report #36467
[architecture] Preventing duplicate payment processing in distributed webhooks
Use client-generated idempotency keys with server-side TTL, storing them with a unique database constraint on \(key, resource\_type\) and rejecting duplicates within your window of uncertainty \(typically 24 hours\).
Journey Context:
Network retries and client timeouts create duplicate processing risks that server-side deduplication cannot catch because the original request may still be in flight. Client-generated keys \(UUIDv4 or KSUID\) allow the server to recognize retries immediately. The critical insight is that application-layer checks race with inserts; only database unique constraints provide linearizability. Stripe's implementation uses a 24-hour replay window; after that, keys are eligible for garbage collection. This pattern is essential for financial operations, inventory reservation, and any 'exactly-once' side effects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:41:20.637092+00:00— report_created — created