CS FundamentalsHardGATE CS · Product-company placement
Two transactions each read row X under a shared lock and later want to update it, so each requests an upgrade to an exclusive lock. What happens under strict 2PL, and what is the usual remedy?
- A. Both upgrades succeed because they hold the same lock
- B. They deadlock; taking an update (U) lock at read time lets only one of them plan an upgrade
- C. The second upgrade waits until the first commits, so no deadlock is possible
- D. Strict 2PL releases shared locks early, so the upgrades go through in turn
Correct answer: B. They deadlock; taking an update (U) lock at read time lets only one of them plan an upgrade
Each waits for the other's shared lock to be released before it can get X, and neither releases until commit: a deadlock. U locks are compatible with S but not with other U locks, so only one transaction can be waiting to upgrade.
More DBMS and SQL questions
- After ARIES analysis the dirty page table holds P1 (recLSN 40), P2 (recLSN 25) and P3 (recLSN 60); the last checkpoint began at LSN 30…
- A DBMS uses deferred database modification: no change reaches the database before its transaction commits (NO-STEAL), but committed…
- A B+ tree stores 1,000,000 keys. Each internal node has at most 50 children (at least 25, except the root, which needs at least 2), and…
- R occupies 1000 blocks and S 500 blocks; 50 buffer blocks are available. Ignoring the cost of writing the result, what does a Grace hash…
- A table has 1,000,000 rows stored 20 per block. An unclustered B+ tree index fetches each matching row with one random block read (ignore…
- R(A, B) = {(1, x), (2, y), (3, z)} and S(B, C) = {(x, 5), (x, 6), (w, 7)}. How many tuples are in the natural full outer join of R and S?