Strict and rigorous two-phase locking worked schedule

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

Share on WhatsApp

← RGPV CS-502 DBMS November 2023 solved question paper

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

Question (restated): Convert the supplied locking schedule to strict and rigorous 2PL, correcting the lock required for writing A.

Answer

The supplied schedule acquires a shared lock on A but later writes A. A shared lock permits reading, not writing. The transaction must obtain an exclusive lock on A before the write, either initially or by upgrading during the growing phase. Since the arithmetic shown only modifies B, the write of A is retained as specified without inventing a new arithmetic operation.

Strict 2PL holds all exclusive locks until commit or abort; shared locks may be released earlier after the growing phase. Rigorous 2PL holds both shared and exclusive locks until commit or abort. Because the supplied schedule writes both A and B, both locks must be exclusive, and the two corrected schedules coincide.

LOCK-X(A)
READ(A)
LOCK-X(B)
READ(B)
B := B + A
WRITE(A)
WRITE(B)
COMMIT
UNLOCK(A)
UNLOCK(B)

An equivalent approach acquires S(A), reads A, acquires X(B), reads B, upgrades S(A) to X(A) before WRITE(A), and holds both exclusive locks until commit. An upgrade is a lock acquisition and must occur before any release. In practice the DBMS releases locks as part of transaction completion.

If the printed WRITE(A) were unintended, A could remain shared. Strict 2PL would then permit releasing A after its last read and after all lock acquisitions, whereas rigorous 2PL would retain it until commit. This is an alternative interpretation, not a silent correction of the question.

Both protocols prevent dirty reads of uncommitted writes and simplify recovery. They may reduce concurrency and can cause deadlocks, which require detection or prevention.

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

← RGPV CS-502 DBMS November 2023 solved question paper

Discussion

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

Sign in to participate in the discussion.

Join the discussion