Learn

VISUAL GUIDE · APIS & QUEUES

When a job runs twice

Step 6 of 10: Worker B runs it again

STEP 6 / 10ORIGINAL SKETCH
enqueuelease jobdebit order 42redeliverdebit order 42Checkout APIJob queuelease 30 sWorker AWorker BLedger DBwallets + done keyscharged twice
A checkout API enqueues a charge job; worker A leases it and writes to the ledger database but its acknowledgement is lost; the queue redelivers to worker B, which writes again unless an idempotency key stops it; an external card provider can also receive the key.
6 / 10
  1. Enqueue
  2. Lease
  3. Side effect
  4. Ack lost
  5. Timeout
  6. Redelivery
  7. At-least-once
  8. Dedupe key
  9. Conditional write
  10. External effects

STEP 6 OF 10 · REDELIVERY

Worker B runs it again

Worker B leases job 7, sees an ordinary charge, and debits the wallet another ₹499. Worker B did nothing wrong. It followed the job exactly.

The customer has now paid twice for one order.

Why it matters. Duplicates do not need a bug. A correct queue and correct workers produce them whenever an acknowledgement is lost.