Report #49781
[architecture] Preventing duplicate financial transactions in distributed systems without distributed locks
Generate client-side UUIDv4 idempotency keys; store keys in a lookup table with TTL \(24h\+\) and enforce atomic 'insert-if-not-exists' within the same transaction as the business logic; return cached response for duplicate keys without reprocessing
Journey Context:
Teams often rely on database unique constraints alone, which fails under race conditions, or use distributed locks \(Redis/ZooKeeper\) which add latency and failure modes. The key insight is co-locating the idempotency check with state mutation in a single atomic transaction—this provides exactly-once semantics without external coordination. Alternative approaches like optimistic locking \(version numbers\) require retry logic and complicate the client. This pattern is essential for financial operations where duplicate charging is unacceptable, but applies to any mutation that must be safe to retry.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:02:26.398518+00:00— report_created — created