Build a lock manager and deadlock detector

The queues of transactions waiting on each other, drawn next to the engine’s split-second latches. This lesson builds the first half: the table that says who holds what, who is waiting, and who has to give up.
Before you start. Locks, Latches & Transactions taught strict two-phase locking, the wait-for graph and a forced deadlock on a real Postgres. The Database That Won't Answer showed a lock queue freezing an app. Transactions (MVCC) built snapshots, which avoid locks for readers, and said row locks were not built. This lesson builds them. A graph with a cycle is the only idea from Graphs (BFS, DFS, Dijkstra, topological sort) you need. The code is in teaching/code/database-internals/04-locks.