Module 5 · Transactions and concurrency control
Episode 33 The Anomalies
▶ This video is coming to YouTube soon.
The five classic anomalies of concurrent transactions, each built as a two-transaction timeline and then reproduced in real Postgres: READ UNCOMMITTED that never reads dirty data, a non-repeatable read and a phantom at READ COMMITTED, a lost update from read-modify-write, and write skew (two doctors on call) at REPEATABLE READ, stopped only by SERIALIZABLE.
Chapters
- 0:00Intro
- 0:14Two doctors, one rule
- 0:38Dirty read: a value nobody committed
- 1:14Proof: Postgres has no dirty reads
- 1:45Non-repeatable read: same row, new value
- 2:16Proof: READ COMMITTED vs. a snapshot
- 3:02Phantom: same query, a new row
- 3:32Proof: a phantom, then none
- 4:07Lost update: two writes, one survives
- 4:54Proof: a lost update, then a refusal
- 6:09The code: read-modify-write and its fixes
- 6:41Write skew: two good choices, one bad result
- 7:19Proof: write skew, then SERIALIZABLE
- 8:34Which anomalies each level allows, in Postgres
- 9:03Recap
- 9:27Next: Serializability