Recall & Review
beginner
What is Two-phase locking (2PL) in database systems?
Two-phase locking (2PL) is a method used in databases to control how transactions access data to avoid conflicts. It ensures that transactions lock data before using it and unlock it only after finishing, following two phases: growing (locking) and shrinking (unlocking).
Click to reveal answer
beginner
What are the two phases in Two-phase locking (2PL)?
The two phases are:<br>1. Growing phase: The transaction acquires all the locks it needs and cannot release any lock.<br>2. Shrinking phase: The transaction releases locks and cannot acquire any new locks.
Click to reveal answer
beginner
Why is Two-phase locking important in databases?
It helps keep data correct and consistent when many transactions happen at the same time by preventing conflicts and ensuring transactions do not interfere with each other.
Click to reveal answer
intermediate
What happens if a transaction tries to lock data during the shrinking phase in 2PL?
It is not allowed. Once a transaction starts releasing locks (shrinking phase), it cannot get any new locks. This rule helps avoid conflicts and ensures consistency.
Click to reveal answer
intermediate
How does Two-phase locking (2PL) prevent deadlocks?
2PL itself does not prevent deadlocks but can cause them. Deadlocks happen when transactions wait for each other’s locks. Additional methods like timeout or deadlock detection are used alongside 2PL to handle deadlocks.
Click to reveal answer
What is the first phase in Two-phase locking (2PL)?
✗ Incorrect
The first phase is the growing phase where the transaction acquires all the locks it needs.
During which phase in 2PL can a transaction release locks?
✗ Incorrect
Locks can only be released during the shrinking phase.
What does Two-phase locking (2PL) help to ensure in databases?
✗ Incorrect
2PL helps ensure data consistency and isolation between transactions.
Can a transaction acquire new locks after it starts releasing locks in 2PL?
✗ Incorrect
Once a transaction starts the shrinking phase by releasing locks, it cannot acquire any new locks.
Does Two-phase locking (2PL) prevent deadlocks by itself?
✗ Incorrect
2PL can cause deadlocks; additional methods like deadlock detection are needed to handle them.
Explain the two phases of Two-phase locking (2PL) and why they are important.
Think about when locks are acquired and released.
You got /4 concepts.
Describe how Two-phase locking (2PL) helps maintain data integrity when multiple transactions run at the same time.
Consider what happens if transactions access the same data simultaneously.
You got /4 concepts.