Two-phase locking and strict 2PL

December 4, 2026 · Team EasyExamNotes · 5 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS December 2024 solved question paper

← RGPV CS-502 DBMS November 2022 solved question paper

← RGPV CS-502 DBMS December 2020 solved question paper

← RGPV CS-502 DBMS June 2025 solved question paper

← RGPV CS-502 DBMS May 2024 solved question paper

RGPV Previous Year Examination Question

B.Tech. V Semester | CS-502 (GS) | December 2024 | 6(b)

Question (restated): Define two-phase locking and compare it with strict two-phase locking.

Answer

Two-phase locking and strict 2PL
Two-phase locking and strict 2PL — conceptual illustration

Two-phase locking (2PL)

Two-phase locking is a concurrency-control protocol that ensures conflict serializability. Transactions acquire shared locks for reading and exclusive locks for writing. Shared locks can coexist on the same item, but an exclusive lock conflicts with other locks.

Phases

During the growing phase a transaction may acquire locks but cannot release any. During the shrinking phase it may release locks but cannot acquire new ones. The point at which it obtains its final lock is called the lock point. Serial order can be determined by lock points.

Strict two-phase locking

Strict 2PL follows the two-phase rule and additionally retains all exclusive locks until commit or abort. Shared locks may be released earlier provided the two-phase rule is respected. Rigorous 2PL retains both shared and exclusive locks until completion.

Illustrative schedule

Basic 2PL: T1 lock-X(A), write(A), unlock(A)
           T2 lock-S(A), read(A), unlock(A)
           T1 abort
Strict 2PL: T1 lock-X(A), write(A)
            T2 requests lock-S(A) and waits
            T1 commits, unlock(A)
            T2 reads committed A

In the basic schedule T2 may read an uncommitted value and require cascading rollback if T1 aborts. Strict 2PL prevents this dirty read by retaining the exclusive lock.

Comparison

Property Basic 2PL Strict 2PL
Conflict serializability Guaranteed Guaranteed
Exclusive lock release Shrinking phase Commit or abort
Cascading rollback Possible Prevented
Deadlock Possible Possible

Both protocols may require deadlock detection or prevention. Strict 2PL simplifies recovery and is widely used because transactions cannot read or overwrite uncommitted writes, although holding locks longer may reduce concurrency.

Further reading

Silberschatz, Korth and Sudarshan, Database System Concepts; Elmasri and Navathe, Fundamentals of Database Systems.


RGPV CS-502 (GS) | November 2022 | Q7(b) | 7 marks

Question (restated): Explain two-phase locking and its variants with an example.

Answer

Two-phase locking (2PL) divides a transaction’s lock operations into a growing phase, during which locks may be acquired, and a shrinking phase, during which locks may be released but no new locks acquired. Shared locks permit concurrent reading; exclusive locks prevent conflicting access.

Example

T1: X-lock(A), Read(A), Write(A), X-lock(B),
    Read(B), Write(B), Unlock(A), Unlock(B), Commit

The lock point occurs when T1 acquires its last lock on B. The schedule obeys basic 2PL because no lock is acquired after the first unlock. However, releasing exclusive locks before commit can expose uncommitted values.

Variant Rule Property
Basic Growing then shrinking Conflict serializability; deadlocks possible
Conservative Acquire all required locks before execution Avoids deadlock if acquisition is atomic
Strict Hold exclusive locks until commit/abort Prevents cascading rollback from dirty writes/reads
Rigorous Hold all shared and exclusive locks until commit/abort Stronger release discipline

In strict 2PL, T1 commits before unlocking A and B. If T2 requests a shared lock on A while T1 holds its exclusive lock, T2 waits. In rigorous 2PL, even shared locks are retained until termination. Deadlocks can still occur in strict and rigorous variants, so detection or prevention is required. Basic 2PL guarantees conflict serializability by ordering transactions according to their lock points.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts.

December 2020 examination question

Explain 2PL using an example.

In basic 2PL, a transaction acquires locks during its growing phase and releases locks during its shrinking phase. Once it releases any lock it cannot acquire another. The instant it obtains its final lock is its lock point. Ordering transactions by lock points yields a conflict-equivalent serial order.

Example: T1 obtains X(A), reads and updates A, obtains X(B), updates B, then releases A and B. T2 requesting A while T1 holds it waits. T1 must not acquire a new lock after releasing A. Basic 2PL can still cause deadlock and cascading rollback. Strict 2PL retains exclusive locks until commit or abort; rigorous 2PL retains both shared and exclusive locks until completion. Conservative 2PL acquires all locks before execution.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts.

June 2025 – Q7(a)

Explain two-phase locking and how it ensures serializability.

In the growing phase a transaction acquires locks and releases none; in the shrinking phase it releases locks and acquires none. Shared locks permit compatible reads; exclusive locks protect writes. The lock point is the instant of the final lock acquisition. Conflicting operations must respect lock compatibility, and ordering transactions by lock points yields a conflict-equivalent serial order. Strict 2PL additionally holds exclusive locks until commit or abort, preventing cascading rollback due to dirty reads of written data. Basic 2PL can deadlock and does not itself guarantee strictness. Example: T1 locks X, writes X, commits and unlocks; T2 then locks X and reads it.

https://easyexamnotes.com/wp-content/uploads/2026/12/two-phase-locking-strict-2pl-jun2025.png


May 2024 — Q4(a)

Question (restated): Explain two-phase locking and why it guarantees serializability.

Answer

Two-phase locking (2PL) divides each transaction into a growing phase, when locks may be acquired but not released, and a shrinking phase, when locks may be released but no new locks acquired. Shared locks permit compatible reads; exclusive locks protect writes. The lock point is the instant at which a transaction obtains its final lock. For any conflicting operations ordered Ti before Tj, Ti must release the incompatible lock before Tj acquires it; therefore Ti’s lock point precedes Tj’s. A cycle in the precedence graph would require a cycle in this strict temporal ordering, which is impossible. Thus compliant schedules are conflict serializable. Basic 2PL can deadlock and permit cascading aborts. Strict 2PL retains exclusive locks until commit or abort; rigorous 2PL retains all locks until completion. Deadlock detection or prevention is still necessary.

Growing: acquire locks|Lock point|Shrinking: release locks
Two-phase locking — schematic illustration

← RGPV CS-502 DBMS December 2024 solved question paper

← RGPV CS-502 DBMS November 2022 solved question paper

← RGPV CS-502 DBMS December 2020 solved question paper

← RGPV CS-502 DBMS June 2025 solved question paper

← RGPV CS-502 DBMS May 2024 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion