Quick Decision Rule: When A mobile checkout client retries a POST /charge call after a 504 Gateway Timeout while the upstream payment processor may have already succeeded, choose Client-generated Idempotency-Key persisted in a unique DB constraint storing the first committed response.
| Trigger Condition | A mobile checkout client retries a POST /charge call after a 504 Gateway Timeout while the upstream payment processor may have already succeeded |
|---|---|
| Recommended Choice | Client-generated Idempotency-Key persisted in a unique DB constraint storing the first committed response |
| Classic Trap | Blindly retrying non-idempotent POST writes causes duplicate customer charges; retries without server-side idempotency turn network glitches into financial incidents. |
| Verification | Audited on 2026-11-23 · Distributed Systems Core · 2026 |
30-SECOND DECISION TRAP CHECK · RELIABILITY
Users report being double-charged on flaky mobile networks after an engineer added automatic 3x client retries on HTTP 504 timeouts for `POST /v1/payments`. What is the missing safeguard?
A 504 timeout does not mean the server failed to charge the card—only that the response timed out. Idempotency keys ensure retries safely return the original outcome without charging twice.
Trap: Retries on non-idempotent POST endpoints without server-side Idempotency-Key deduplication create double charges.