Which statement best describes the Two-Phase Locking (2PL) protocol in database systems?
Think about how 2PL controls when locks can be acquired and released to avoid conflicts.
Two-Phase Locking requires a growing phase where all locks are acquired and a shrinking phase where locks are released, preventing conflicts and ensuring serializability.
In lock-based protocols, which of the following lock pairs are compatible, allowing concurrent access?
Consider which locks allow reading and which prevent others from accessing.
Shared locks allow multiple transactions to read the same data concurrently, so they are compatible. Exclusive locks prevent others from accessing the data.
Consider two transactions T1 and T2. T1 holds a lock on resource A and requests a lock on resource B. T2 holds a lock on resource B and requests a lock on resource A. What is the outcome?
Think about what happens when two transactions wait for each otherβs locked resources.
This is a classic deadlock where each transaction waits for a resource held by the other, causing an indefinite wait.
Which of the following correctly distinguishes Strict Two-Phase Locking (Strict 2PL) from Rigorous Two-Phase Locking (Rigorous 2PL)?
Focus on when locks are released in each protocol.
Strict 2PL holds exclusive locks until commit to prevent dirty reads, while shared locks can be released earlier. Rigorous 2PL holds all locks until commit, providing stronger guarantees.
How does using finer lock granularity (e.g., row-level locks) compared to coarser granularity (e.g., table-level locks) affect concurrency and overhead in a database system?
Think about how locking smaller parts affects how many transactions can run simultaneously and the cost of managing locks.
Finer granularity allows more transactions to access different parts of data simultaneously, improving concurrency. However, it requires managing many more locks, increasing overhead and complexity.