Variations of 2PL: 8 Solved MCQs and 2 Worked Questions on Strict, Rigorous and Conservative Locking

Test the differences between basic, strict, rigorous and conservative 2PL. Eight objective questions and two worked schedules show how each lock rule changes the answer.

KnowledgeGate Team

Exam prep & CS education

Updated 18 Aug 20268 min read

Strict, rigorous and conservative 2PL all remain two-phase locking, but they answer different questions. Which locks must be acquired early? Which must survive until commit? These small wording changes decide most answers. The safest approach is to name the acquisition or release rule first, then test the schedule line by line instead of guessing from the protocol label.

Answer each question before reading its explanation. Two facts settle most of them. All four variants produce conflict serializable schedules, so serializability never separates them. What differs is deadlock exposure and cascading aborts, and both follow directly from when a lock is taken and when it is given up. If the vocabulary of locks, schedules and serializability needs a refresh, revise transaction schedules and concurrency control first.

1. 2PL guarantees, deadlocks and cascading aborts

Protocol

Lock rule

Key result

Basic 2PL

No new lock after the first unlock

Conflict serializable; deadlock and cascading aborts possible

Conservative 2PL

Preclaim every required S and X lock

Conflict serializable; prevents lock-wait deadlock

Strict 2PL

Hold X locks through commit or abort

Cascadeless; can deadlock

Rigorous 2PL

Hold S and X locks through commit or abort

Cascadeless; can deadlock

Q1. Identify the deadlock-free variant

Which of the following is/are true:

  • (a) 2PL is conflict serializable and deadlock free

  • (b) conservative 2PL is conflict serializable and deadlock free

  • (c) rigorous 2PL is conflict serializable and deadlock free

  • (d) strict 2PL is conflict serializable and deadlock free

Answer: (b). All four variants are conflict serializable. Only conservative 2PL preclaims the complete lock set; strict and rigorous transactions can still form wait cycles.

Q2. Strict schedules and cascading aborts

Which of the following statements is/are true?

I. Strict 2PL ensures strict schedules

II. Basic 2PL allows cascading aborts

  • (a) Only I

  • (b) Only II

  • (c) Both I & II

  • (d) None of the above

Answer: (c). Strict 2PL holds every exclusive lock through commit or abort, so no transaction can read or overwrite an uncommitted write. Basic 2PL may release one earlier, allowing a dependent read and cascading abort.

2. Conservative 2PL MCQs: preclaim every required lock

The test is simple: list the complete S/X lock set before the first database operation. Preclaiming is not limited to exclusive locks, and it does not require locks to survive until commit unless strictness is added separately.

Q3. Classify the lock sequence

Which protocol is satisfied by following transaction:

LOCK - X(A)
LOCK - S(B)
R(A)
R(B)
W(A)
UNLOCK(A)
COMMIT
UNLOCK(B)
  • (a) Strict 2PL

  • (b) Rigorous 2PL

  • (c) Conservative 2PL

  • (d) None of the above

Answer: (c). The required set is {X(A), S(B)}, acquired before R(A), the first database operation. UNLOCK(A) precedes COMMIT, so the schedule is neither strict nor rigorous, but it remains conservative 2PL.

Q4. What must be acquired at the beginning?

In conservative two phase locking protocol, a transaction

  • (a) Should release exclusive locks only after the commit operation

  • (b) Should release all the locks only at beginning of the transaction

  • (c) should acquire all the locks at beginning of the transaction

  • (d) Should acquire all the exclusive locks at beginning transaction

Answer: (c). A transaction acquires its complete shared and exclusive lock set before execution. If one is unavailable, it waits without a partial set, removing circular wait among compliant transactions.

3. Strict and rigorous 2PL MCQs: which locks survive until commit

Strict 2PL retains X locks through commit or abort. Rigorous 2PL retains both S and X locks through that boundary.

Q5. The rigorous release rule

In a Rigorous 2 phase protocol

  • (a) All shared locks held by the transaction are released after the transaction is committed

  • (b) All exclusive locks held by the transaction are released after the transaction is committed

  • (c) All locks held by the transaction are released after the transaction is committed

  • (d) All locks held by the transaction are released before the transaction is committed

Answer: (c). Rigorous 2PL retains every shared and exclusive lock through commit. Strict 2PL imposes that hold-until-commit rule only on exclusive locks.

Q6. GATE 2007: choose the strict 2PL scheme

Consider the following two transactions : T1 and T2.

T1: read(A); read(B); if A = 0 then B <- B + 1; write(B);
T2: read(B); read(A); if B != 0 then A <- A - 1; write(A);

Which of the following schemes, using shared and exclusive locks, satisfy the requirements for strict two phase locking for the above transactions?

(a) Scheme A

Option A. T1 takes shared locks on A and B, reads both, writes B, commits, then unlocks A and B. T2 mirrors the same sequence with shared locks on B and A.

(b) Scheme B

Option B. T1 takes exclusive locks on A and B, writes B, unlocks A before its commit, then unlocks B. T2 takes exclusive locks on B and A and unlocks A both before and after its commit.

(c) Scheme C

Option C. T1 takes a shared lock on A and an exclusive lock on B, writes B, unlocks A, commits, then unlocks B. T2 mirrors that order on B and A.

(d) Scheme D

Option D. T1 takes a shared lock on A and an exclusive lock on B, writes B, then unlocks both A and B before committing. T2 mirrors the same order on B and A.

Answer: (c), Scheme C. T1 takes S(A) and X(B), releasing only S(A) before commit. T2 takes S(B) and X(A), releasing only S(B) before commit. Every X lock survives until commit, and neither transaction acquires a lock after its first unlock. Possible deadlock does not disqualify C because strict 2PL is not deadlock-free.

4. Strict 2PL, recoverability and Thomas' Write Rule

Q7. Evaluate the two statements

Consider the following two statements about database transaction schedules:

I. Strict two-phase locking protocol generates conflict serializable schedules that are also recoverable.

II. Timestamp-ordering concurrency control protocol with Thomas’ Write Rule can generate view serializable schedules that are not conflict serializable.

Which of the above statements is/are TRUE?

  • (a) I only

  • (b) II only

  • (c) Both I and II

  • (d) Neither I nor II

Answer: (c). Strict 2PL obeys 2PL and prevents dirty reads and dirty overwrites, so I is true. Thomas' Write Rule may ignore an obsolete write, admitting some view-serializable schedules that are not conflict serializable. It is a timestamp-ordering rule, not a 2PL variation.

For another mixed set on ACID properties and locking, continue with DBMS Transaction MCQs: 12 Solved (ACID, Locking).

5. Two-phase locking vs two-phase commit: catch the faulty classification

Two-phase locking controls concurrent access and can guarantee conflict serializability. Two-phase commit coordinates atomic commit across participants. It does not by itself guarantee serializability or prevent, detect or recover from deadlock.

Q8. Read the protocol name carefully

Which of the following is correct with respect to Two phase commit protocol?

  • (a) Ensures serializability

  • (b) Prevents Deadlock

  • (c) Detects Deadlock

  • (d) Recover from Deadlock

Answer: none of the four options is correct as printed. Two-phase commit is an atomic commit protocol. It coordinates the participants of a distributed transaction through a prepare phase and a commit phase so that all of them commit or all of them abort. It does not order conflicting operations, so it cannot ensure serializability, and it carries no deadlock machinery, so it neither prevents, detects nor recovers from deadlock. Answer keys that mark (a) are reading the question as two-phase locking. Change that one word and (a) becomes correct, which is exactly the trap the wording sets.

6. Worked schedule question: Wait-Die, detection and conservative strict 2PL

Q9. Work both schedules under three mechanisms

Consider the following sequences of actions executed in a DBMS:
Sequence S1:
T1:R(X), T2:W(X), T2:W(Y), T3:W(Y), T1:W(Y), T1:Commit, T2:Commit, T3:Commit
Sequence S2:
T1:R(X), T2:W(Y), T2:W(X), T3:W(Y), T1:W(Y), T1:Commit, T2:Commit, T3:Commit
For each sequence, explain how the following concurrency control mechanisms handle execution:
1. Strict 2PL with timestamp-based deadlock prevention (Wait-Die)
2. Strict 2PL with deadlock detection
3. Conservative Strict 2PL

Use the explicit assumption TS(T1)=1, TS(T2)=2, TS(T3)=3, with a smaller timestamp meaning an older transaction.

S1 with Wait-Die. T1 obtains S(X). Younger T2 requests X(X) and dies because T1 is older. T3 can obtain X(Y). When T1 later requests X(Y), it is older than T3, so it waits and finishes after T3 releases Y.

S2 with Wait-Die. T1 obtains S(X). T2 obtains X(Y) and then requests X(X); because T2 is younger than T1, it dies and releases Y. T3 then obtains X(Y). When the older T1 requests X(Y), it waits and finishes after T3 releases Y.

S1 with detection. The waits produce T2 -> T1 and T1 -> T3. There is no directed cycle, so there is no deadlock.

S2 with detection. T2 holds X(Y) and waits for T1's lock on X, producing T2 -> T1. T3 waits for T2's Y lock, producing T3 -> T2. T1 then waits for Y, producing T1 -> T2. The two-node cycle T1 -> T2 -> T1 is a deadlock, so a chosen victim, for example younger T2, is aborted.

Conservative strict 2PL. Preclaim T1:{S(X), X(Y)}, T2:{X(X), X(Y)} and T3:{X(Y)}. One valid order for either sequence is T1, then T2, then T3. A transaction that cannot claim its whole set waits without partial locks, so no lock-wait deadlock forms.

Two side-by-side wait-for graphs using TS(T1)=1, TS(T2)=2 and TS(T3)=3. S1 shows edges T2 -> T1 and T1 -> T3 with the label "no cycle". S2 shows T2 -> T1 and T1 -> T2 as an orange two-node cycle, plus T3 -> T2, with "abort younger T2" marked beside the cycle.

7. The full 2PL protocol and all major variations

Q10. Explain the protocol and its phases

Explain the Two-Phase Locking (2PL) protocol in concurrency control. Detail its two distinct phases and its major variations.

Consider S(X), R(X), X(Y), W(Y). The transaction is in its growing phase while acquiring S(X) and X(Y). Its lock point is immediately after X(Y), the last acquisition. The first unlock begins the shrinking phase, and no new lock may be acquired from that point.

Variation

Exact rule

Main outcome

Basic 2PL

No new acquisition after the first release

Conflict serializable; may deadlock or cascade

Strict 2PL

Hold all X locks until commit or abort

Conflict serializable and cascadeless

Rigorous 2PL

Hold all S and X locks until commit or abort

Cascadeless; lock-release order follows commit order

Conservative 2PL

Acquire the complete S/X set before the first operation

Conflict serializable and deadlock-free through preclaiming

All four preserve conflict serializability. Conservative 2PL changes when locks are acquired, while strict and rigorous 2PL strengthen when locks are released.

8. Variations of 2PL: the short version and next practice step

Use this four-line memory test:

  • Conservative: when are all required locks acquired?

  • Strict: are all X locks held through commit or abort?

  • Rigorous: are all S and X locks held through commit or abort?

  • Basic: did lock acquisition stop after the first release?

When a question hands you a lock sequence instead of a protocol name, work it in that order: check the two-phase rule first (did any acquisition follow a release?), then the preclaim rule, then the position of every unlock relative to commit. The labels are not a ladder. The sequence in Q3 satisfies conservative 2PL and still fails strict 2PL, because it releases X(A) before it commits.

GATE aspirants can place this topic inside GATE Guidance by Sanchit Sir. Placement learners can build the same DBMS foundation through Computer Science Fundamentals for Placements by Sanchit Sir. For the wider subject route, use GATE CS Exam Preparation, then return to these questions and justify each answer from a lock rule rather than memory.