Categories of Two Phase Locking
Last Updated :
11 Aug, 2025
Two-Phase Locking (2PL) is a crucial technique in database management systems designed to ensure consistency and isolation during concurrent transactions. This article will cover the three main types of 2PL: strict 2PL, rigorous 2PL and conservative 2PL highlighting the differences in their locking protocols
There are three categories:
- Strict 2-PL
- Rigorous 2-PL
- Conservative 2-PL
Strict Two-Phase Locking Protocol (Strict 2PL)
The Strict Two-Phase Locking Protocol is a variation of the Two-Phase Locking (2PL) protocol that adds a specific rule for releasing exclusive (X) locks. In addition to following the two phases (growing and shrinking), strict 2PL ensures that:
- All Exclusive (X) Locks are Held Until the Transaction Commits or Aborts:
- A transaction can acquire locks during the growing phase.
- It cannot release any exclusive locks until it has completed its operations and either committed or aborted.
- This rule prevents other transactions from accessing data modified by an ongoing transaction, ensuring data consistency.
- Benefits:
- Recoverable Schedule: Ensures that if a transaction fails, no other transactions depend on its uncommitted changes.
- Cascadeless Schedule: Prevents cascading rollbacks, as other transactions cannot read uncommitted data.
Strict 2PLThe image demonstrates a Strict Two-Phase Locking (2PL) Protocol scenario with two transactions, T1 and T2 accessing and modifying two database accounts A and B. Here’s a step-by-step explanation:
Initial Database State:
- Account A=1000
- Account B=1000
Steps in the Schedule:
Transaction T1:
- BEGIN: T1 starts and acquires an exclusive lock (X-Lock) on A. This means T1 can read and modify A, and no other transaction can access A during this time.
- T1 reads A and subtracts 100 from it (A=900).
- T1 acquires an X-Lock on B and adds 100 to B (B=1100).
- T1 unlocks A and B only after committing. At this point, the changes made by T1 become visible to other transactions.
Transaction T2:
- BEGIN: T2 starts and tries to acquire a shared lock (S-Lock) on A to read its value.
- T2 waits because T1 is holding an exclusive lock on A. This prevents T2 from reading the uncommitted data ensuring no dirty reads.
- Once T1 commits and releases the lock on A, T2 acquires the S-Lock on A, reads A=900 and moves on.
- T2 acquires an S-Lock on B, reads B=1100 and calculates A+B=2000.
- T2 unlocks both A and B after committing.
Final Output:
- After T1 commits, T2 reads the updated values of A and B and the result A+B=2000 reflects the committed changes.
Rigorous Two-Phase Locking (Rigorous 2PL)
Rigorous 2PL is a stricter version of the Two-Phase Locking (2PL) protocol. In this protocol:
- All locks (both shared and exclusive) are held by a transaction until it either commits or aborts.
- Locks are only released after the transaction finishes, ensuring that no other transaction can access the locked data until the first transaction is fully complete.
This means that no other transaction can read or write the data being used by the current transaction until it is committed or rolled back. This ensures data consistency and avoids issues like dirty reads or cascading rollbacks.
Sequence of transactionsExplantion of the above transactions is given below:
T1 (left column)
- lock-exclusive(A) → T1 locks data item A exclusively.
- lock-exclusive(B) → T1 also locks B exclusively.
- Reads and modifies A: read(A) → A = A + 50 → write(A).
- Reads and modifies B: read(B) → B = B + 100 → write(B).
- commit is performed before releasing any locks.
- unlock(A) and unlock(B) happen after commit.
Follows Rigorous 2PL: No locks are released before the transaction commits.
T2 (right column)
- lock-exclusive(A) → T1 locks A exclusively.
- Reads and modifies A: read(A) → A = A + 50 → write(A).
- commit is executed.
- unlock(A) is done after commit.
Follows Rigorous 2PL: Even with a single item, lock is held until commit.
Hence, it gives us freedom from Cascading Abort which was still there in Basic 2-PL and moreover guarantee Strict Schedules but still, Deadlocks are possible!
Note: The difference between Strict 2-PL and Rigorous 2-PL is that Rigorous is more restrictive, it requires both Exclusive and Shared locks to be held until after the Transaction commits and this is what makes the implementation of Rigorous 2-PL easier.
Conservative Two-Phase Locking (Conservative 2PL)
Conservative 2PL is a variation of the Two-Phase Locking protocol designed to prevent deadlocks entirely. It is also known as the Static-2PL. The key feature of Conservative 2PL is that a transaction acquires all the locks it needs at the very beginning of the transaction before it starts executing. If the transaction cannot acquire all the required locks, it does not proceed and waits until all locks become available.
Conservative 2PL ProtocolThis example demonstrates Conservative Two-Phase Locking (Conservative 2PL), where each transaction acquires all the locks it needs at the beginning of the transaction to avoid deadlocks. Here's a detailed explanation of how it aligns with the principles of Conservative 2PL:
Transaction T1 (left column):
- Lock-Exclusive(A): T1 acquires an exclusive lock on A before performing any operation on it.
- Lock-Exclusive(B): Before proceeding further, T1 also acquires an exclusive lock on B ensuring that both resources required by T1 are locked at the start.
- Operations on A: T1 reads the value of A, increments it by 50 and writes the updated value back to A.
- Unlock(A): After completing all operations on A, T1 releases the lock on A.
- Operations on B: T1 reads the value of B, increments it by 100 and writes the updated value back to B.
- Unlock(B): T1 releases the lock on B after finishing all operations.
Transaction T2 (right column):
- Lock-Exclusive(A): T2 attempts to acquire an exclusive lock on A at the start of the transaction. If T1 still holds the lock on A T2 waits until T1 releases it.
- Operations on A: Once T2 acquires the lock it reads A, increments it by 50 and writes the updated value back to A.
- Unlock(A): T2 releases the lock on A, after completing its operations.
Advantages of Conservative 2PL:
- Deadlock-Free: Deadlocks are avoided because a transaction either acquires all required locks at once or waits until it can.
- Efficient Use of Locks: Transactions do not hold partial locks while waiting for others, reducing contention.
- Consistency and Serializability: Like all 2PL variants, it ensures consistent and serializable schedules.
Venn Diagram below shows the classification of schedules that are rigorous and strict. The universe represents the schedules that can be serialized as 2-PL. Now as the diagram suggests, and it can also be logically concluded, if a schedule is Rigorous then it is Strict. We can also think in another way, say we put a restriction on a schedule which makes it strict adding another to the list of restrictions make it Rigorous.

Read more about Conservative 2PL Protocol.
GATE CS | IT 2004 | Question 77
Categories of Two Phase Locking (Strict, Rigorous)
Visit Course
Explore
Basics of DBMS
ER & Relational Model
Relational Algebra
Functional Dependencies & Normalisation
Transactions & Concurrency Control
Advanced DBMS
Practice Questions