Learn

VISUAL GUIDE · APIS & QUEUES

When a job runs twice

Step 3 of 10: Worker A debits the wallet

STEP 3 / 10ORIGINAL SKETCH
enqueuelease jobdebit order 42Checkout APIJob queuelease 30 sWorker ALedger DBwallets + done keysbalance −499
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.
3 / 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 3 OF 10 · SIDE EFFECT

Worker A debits the wallet

Worker A subtracts ₹499 from the customer's wallet and commits. The money has moved. This is the side effect: a change in the world that someone will notice if it happens twice.

Why it matters. Name the side effect explicitly. It is the only part of the job that is dangerous to repeat.