Two withdrawals, one balance check
Withdrawing money reads the balance, checks it covers the amount, then writes the new balance. Two withdrawals arriving in the same instant both read 100, both decide 80 is fine, and both write their result.
The account ends at 20 after 160 was taken. Neither transaction did anything invalid — they just both read before either wrote.
Make the second transaction wait for the first.
Components — tap one, then tap a slot on the diagram
!Two concurrent withdrawals both passed the balance check. The account went to 20 after 160 was taken.
Outside every boundary: Balance row (FAILED: overdrawn), Withdrawal A (reads 100), Withdrawal B (also reads 100; FAILED: stale read), an empty slot for the on the read Connections: Withdrawal A calls on the read — locks the row (step 1) Withdrawal B calls on the read — waits (step 2) on the read calls Balance row (step 3)
Balance rowoverdrawn
Withdrawal Areads 100
Withdrawal Balso reads 100stale read