Module 5 · Transactions and concurrency control
Episode 37 Timestamp Ordering and OCC
▶ This video is coming to YouTube soon.
How do you keep transactions serializable without waiting for locks? This episode animates basic timestamp ordering (read and write timestamps, too-late reads and writes, restarts, the Thomas write rule) and optimistic concurrency control with backward validation, then shows Postgres's REPEATABLE READ failing the second updater with 40001 and an application-level version column doing OCC by hand.
Chapters
- 0:00Intro
- 0:12Three ways to stay serializable
- 0:35No control at all: a lost update
- 1:06Basic timestamp ordering
- 1:44A read that arrives too late
- 2:40Writes too late, and the Thomas write rule
- 3:26What timestamps cost
- 3:52Optimistic concurrency control
- 4:18Validation catches the stale read
- 5:19The code: backward validation
- 5:49Postgres: the first updater wins
- 6:37OCC in your app: a version column
- 7:22Trade-offs
- 7:55Recap
- 8:25Next: MVCC