Check-then-insert idempotency let 216 duplicate charges through when 1,000 payments were each retried five times at once, while an atomic Postgres INSERT ON CONFLICT or Redis SET NX claim produced 0.
When 100 workers crashed after charging but before marking the key done, the Postgres claim, Redis and a transaction around an external call each charged 100 customers twice.
Passing the same key to the payment processor, with a unique constraint on its side effect, took every design to 0 duplicates, so keep local writes in one Postgres transaction and forward keys to