AlgoPlus//structures / two-phase-locking
Read the theory

Two-Phase Locking (2PL)

Acquire all locks first (growing), then release (shrinking) — the rule that guarantees serializability.

T1
T2
Legend
Growing
Shrinking
Blocked / locked
AI Tutor Workspace
In a nutshell
Two-phase locking keeps concurrent transactions safe by making each one lock the data it touches. Every transaction has a growing phase where it only takes locks, then a shrinking phase where it only releases them — never mixing the two. That discipline forces conflicting transactions to wait their turn, guaranteeing a serializable result, at the cost of possible deadlocks.
Ready
Press play to begin the cinematic walkthrough.
2PL splits a transaction into a growing phase (only acquire locks) then a shrinking phase (only release). Holding locks past the lock point forces conflicting transactions to wait, guaranteeing a serializable schedule.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Two-Phase Locking (2PL).