DBMS Topics
Two-Phase Locking 2PL
Last Updated : 21 May, 2026
Two-Phase Locking 2PL is a concurrency control protocol that guarantees conflict serializability by organizing all lock operations into exactly two phases:
Recap
Two-Phase Locking (2PL) is a concurrency control protocol that guarantees conflict serializability by organizing all lock operations into exactly two phases:
Why 2PL Ensures Serializability
The lock point of a transaction determines its position in the equivalent serial order.
Worked Example — 2PL Schedule
| T1 | Transfer ₹1000 from A to B |
| T2 | Transfer ₹500 from B to C |
| T1 | T2: |
Problems with Basic 2PL
Cascading Rollbacks
| T1 ROLLBACK | X must revert to old value |
| T2 used dirty value | T2 must also ROLLBACK! |
| If T3 read T2's write | T3 must rollback too! |
Strict 2PL solves this by holding X-locks until commit.
Strict 2PL (Most Used in Practice)
Strict 2PL Example
Deadlock with 2PL
2PL can lead to deadlocks — two or more transactions waiting for each other's locks indefinitely.
(Deadlocks are handled in the Deadlock topic)
2PL Summary
| Basic 2PL | Strict 2PL | Rigorous 2PL |
|---|---|---|
| S+X released | X locked till | S+X locked till |
| in shrink phase | commit/abort | commit/abort |
| Serializable ✓ | Serializable ✓ | Serializable ✓ |
| Cascading ✗ | No cascading ✓ | No cascading ✓ |
| Dirty reads ✗ | No dirty reads ✓ | No dirty reads ✓ |
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Two-Phase Locking 2PL.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this DBMS topic.
Search Terms
dbms, database management system, database notes, sql, unit, two, phase, locking
Related DBMS Topics