TransactionsdebuggingIntermediate

Money left one account and never arrived at the other

Symptoms

  • A support ticket: a transfer debited the sender but never credited the recipient.
  • It happens rarely, seemingly around deploys or crashes.
-- application code:
db.execute("UPDATE accounts SET balance = balance - :amt WHERE id = :from")
# ... process may die here ...
db.execute("UPDATE accounts SET balance = balance + :amt WHERE id = :to")

Investigate

Inspect areas in any order (0/4 inspected). When you think you know the root cause, commit to it.

The two UPDATE statements
The transactions/ledger tables
Deploy and crash timing
Isolation level