Module 5 · Transactions and concurrency control
Episode 34 Serializability
▶ This video is coming to YouTube soon.
When is an interleaving of transactions safe? This episode builds the precedence (conflict) graph of a schedule step by step, swaps non-conflicting operations to reach a serial order, finds the cycle in the schedule that lost $30, and topologically sorts a three-transaction graph. Then Postgres SERIALIZABLE aborts the cyclic schedule with SQLSTATE 40001 and commits the acyclic one.
Chapters
- 0:00Intro
- 0:17252 ways to interleave
- 0:37Two operations conflict when order matters
- 1:07Every conflict is an edge
- 1:48Conflict equivalence: swap what doesn't conflict
- 2:40A cycle means no serial order
- 3:27Topological order = the serial schedule
- 4:06The code: build the graph, look for a cycle
- 4:34The two schedules we'll run in Postgres
- 5:14Proof: SERIALIZABLE aborts the cycle
- 6:58Conflict-serializable is a safe subset
- 7:26How databases keep the graph acyclic
- 7:50Recap
- 8:16Next: Two-Phase Locking