0
0
DBMS Theoryknowledge~20 mins

Two-phase locking (2PL) in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
2PL Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the Phases of Two-Phase Locking

Which of the following best describes the two phases in the Two-Phase Locking (2PL) protocol?

AGrowing phase where locks are acquired and shrinking phase where locks are released
BShrinking phase where locks are acquired and growing phase where locks are released
CPhase one where transactions execute without locks, phase two where locks are applied
DPhase one where all locks are released, phase two where all locks are acquired
Attempts:
2 left
💡 Hint

Think about when locks can be obtained and when they must be released in 2PL.

📋 Factual
intermediate
2:00remaining
Effect of 2PL on Transaction Serializability

What is the main guarantee provided by the Two-Phase Locking protocol regarding transaction execution?

AIt guarantees transactions will never deadlock
BIt guarantees serializability of concurrent transactions
CIt guarantees transactions will execute faster than without locking
DIt guarantees that transactions will always commit successfully
Attempts:
2 left
💡 Hint

Consider what serializability means for concurrent transactions.

🔍 Analysis
advanced
2:00remaining
Deadlock Possibility in Two-Phase Locking

Which statement correctly describes deadlock behavior in strict Two-Phase Locking?

ADeadlocks can occur because transactions hold locks until commit, potentially waiting on each other
BDeadlocks cannot occur because locks are released immediately after use
CDeadlocks are prevented by releasing all locks before acquiring new ones
DDeadlocks are avoided by allowing transactions to acquire locks in any order
Attempts:
2 left
💡 Hint

Think about how holding locks until commit affects waiting between transactions.

Comparison
advanced
2:00remaining
Difference Between Basic 2PL and Strict 2PL

What is the key difference between basic Two-Phase Locking and Strict Two-Phase Locking?

AStrict 2PL allows lock acquisition after releasing some locks, basic 2PL does not
BBasic 2PL holds all locks until commit, strict 2PL releases locks immediately after use
CStrict 2PL holds all exclusive locks until transaction commit, basic 2PL releases locks during shrinking phase
DBasic 2PL prevents deadlocks, strict 2PL does not
Attempts:
2 left
💡 Hint

Consider when exclusive locks are released in both protocols.

Reasoning
expert
2:00remaining
Impact of Violating the Growing Phase in 2PL

What is the likely consequence if a transaction releases a lock and then later tries to acquire another lock in Two-Phase Locking?

AThe transaction will commit successfully without any problems
BThe transaction will automatically restart without any issues
CThe transaction will deadlock immediately
DThe transaction violates 2PL and may cause non-serializable schedules
Attempts:
2 left
💡 Hint

Recall the rule about acquiring and releasing locks in 2PL phases.