CS FundamentalsVery hardProduct company interview · GATE level
A lock manager grants a request whenever it is compatible with the locks currently held; otherwise the requester waits. The requests arrive in this order: T1 exclusive on A (granted); T2 exclusive on B (granted); T3 shared on C (granted); T1 shared on B; T2 exclusive on C; T4 shared on C; T3 exclusive on A; T4 shared on A. Which statement about the resulting wait-for graph is correct?
- A. It has two cycles; aborting T3 alone does not clear the deadlock, but aborting T2 alone does
- B. It has one cycle, T1 → T2 → T3 → T1; aborting any one of these three clears the deadlock
- C. It has two cycles; aborting T4 alone clears the deadlock
- D. It has no cycle, because T4's shared lock on C is compatible with T3's
Correct answer: A. It has two cycles; aborting T3 alone does not clear the deadlock, but aborting T2 alone does
T1 waits for T2 (B). T2's exclusive request on C conflicts with T3's shared lock, so T2 waits for T3. T4's shared request on C is compatible with the lock actually held (T3's shared lock), so it is granted - and now T2 waits for T4 as well. T3 waits for T1 (A) and T4 waits for T1 (A). Edges: T1 → T2, T2 → T3, T2 → T4, T3 → T1, T4 → T1, giving the cycles T1 → T2 → T3 → T1 and T1 → T2 → T4 → T1. Aborting T3 or T4 breaks only one cycle; aborting T1 or T2, which lie on both, clears the deadlock.
More DBMS and SQL questions
- Transactions T1, T2 and T3 have timestamps 1, 2 and 3. All read and write timestamps of items A and C are initially 0, and the operations…
- A B+ tree uses 4096-byte blocks, 12-byte search keys, 8-byte block pointers and 10-byte record pointers. An internal node with p child…
- A B+ tree holds 10,000 keys in its leaves. A leaf holds at most 20 and at least 10 keys; an internal node has at most 30 and at least 15…
- A file has 200,000 fixed-length records of 200 bytes stored unspanned in 1024-byte blocks. A secondary index is built on a non-ordering…
- Relations R (1000 blocks) and S (200 blocks) are joined with a block nested-loop join using M = 52 buffer blocks: M - 2 blocks hold a…
- Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows…