Questions: Two-Phase Locking

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Transaction T1 holds an exclusive lock on row A and requests a lock on row B. Transaction T2 holds an exclusive lock on row B and requests a lock on row A. Under 2PL, what happens?

A2PL automatically detects the circular wait and aborts the lower-priority transaction
BBoth transactions block indefinitely — a deadlock that 2PL itself does not resolve
C2PL prevents this scenario by requiring transactions to acquire all locks before starting
DT1 is forced to release its lock on A to make progress, then reacquire it later
Question 2 Multiple Choice

A transaction using 2PL acquires a shared lock on row X, reads the data, then releases the shared lock on row X. Later in the same transaction, it needs to acquire a shared lock on row Y. Why does this violate 2PL?

AShared locks cannot be released before exclusive locks in any 2PL implementation
BReleasing the lock on X starts the shrinking phase, so no new lock — including on Y — can be acquired
CRow-level locking in 2PL requires all locks to be acquired before any data is read
DShared locks on different rows are mutually exclusive and cannot both be held
Question 3 True / False

Under Strict 2PL, holding all locks until commit or abort prevents cascading aborts.

TTrue
FFalse
Question 4 True / False

Two-Phase Locking guarantees that deadlocks will seldom occur between transactions in a correctly implemented database.

TTrue
FFalse
Question 5 Short Answer

Why does the 2PL rule — never acquire a lock after releasing one — guarantee serializability?

Think about your answer, then reveal below.