15, 10 chapters
locks and concurrency control
everything.locking
locks and concurrency control
serializability theory, two-phase locking, postgres's lock manager, and the SSI that catches write skew.
- 15.01schedules and serializabilitywhat correct means for interleaved transactions. conflicts, precedence graphs and cycles.
- 15.02two-phase lockinggrow, then shrink. why 2PL guarantees serializability, and strict 2PL avoids cascading aborts.
- 15.03table lock modeseight modes from ACCESS SHARE to ACCESS EXCLUSIVE, and the matrix that decides who waits.
- 15.04how row locks are storedfour strengths, kept in the tuple header instead of the lock table. pgrowlocks shows them.
- 15.05watching locks with pg_lockspg_locks, pg_blocking_pids, and one query that shows who's blocking whom.
- 15.06the lock queuea long SELECT, an ALTER TABLE behind it, and every query behind that frozen. lock_timeout saves the day.
- 15.07inside the deadlock detectorwait-for graphs, deadlock_timeout, soft edges, and how a victim gets chosen.
- 15.08latches, spinlocks and LWLocksthe short locks that protect memory, not rows. why they never show up in pg_locks.
- 15.09timestamp ordering and OCCconcurrency control without locks: order by timestamp, or validate at the end and abort.
- 15.10serializable snapshot isolationSIRead locks, rw-antidependencies, and the dangerous structure that gets you a 40001.