Two-Phase Locking
Two-phase locking (2PL) divides a transaction into a locking phase and an unlocking phase, guaranteeing serializability but risking deadlock.
Purpose
To understand the classic serializable concurrency-control protocol, its deadlock risk, and variants.
Mechanism
Phase one (growing) only acquires locks; phase two (shrinking) only releases. Strict 2PL (S2PL) releases locks only at transaction end, avoiding cascading rollbacks. Strong 2PL (SS2PL) also holds read locks to the end, guaranteeing strict serializability.
Use cases
- Concurrency control design
- Serializability implementation
- Deadlock analysis