Consider the following sequences of actions, listed in the order they are submit
ID: 3589197 • Letter: C
Question
Consider the following sequences of actions, listed in the order they are submitted to the DBMS
Sequence S: T1:R(X), T2:W(X), T2:W(Y), T3:W(Y), T1:W(Y), T1:Commit, T2:Commit, T3:Commit
Assume that the timestamp of transaction Ti is i. For lock-based concurrency control mechanisms, add lock and unlock requests to the previous sequence of actions as per the locking protocol. The DBMS processes actions in the order shown. If a transaction is blocked, assume that all its actions are queued until it is resumed; the DBMS continues with the next action (according to the listed sequence) of an unblocked transaction.
1. describe how the strict 2PL with timestamps used for deadlock prevention handles the sequence based on wait-die policy. assume T1 has the highest priority, T2 has the second highest priority, and T3 has the lowest priority.
2Describe how the strict 2PL with deadlock detection mechanism handles the sequence.Show the waits-for graph if a deadlock cycle develops
Explanation / Answer
1. Assume we use Wait-Die policy.
Sequence S1:
T1 acquires shared-lock on X;
for an exclusive-lock on X, since T2 has a lower priority, it will be aborted When T2 asks;
T3 now gets exclusive-lock on Y; When T1 also asks for an exclusive-lock on Y, which is still held by T3, since T1 has higher priority, T1 will be blocked waiting;
T3 now finishes write, commits and releases all the lock; T1 wakes up, acquires the lock, proceeds and finishes; T2 now can be restarted successfully.
2. In deadlock detection
transactions are allowed to wait, they are not aborted until a deadlock has been detected. (Compared to prevention schema, some transactions may have been aborted prematurely.)
Sequence S1:
T1 gets a shared-lock on X;
T2 blocks waiting for an exclusive-lock on X;
T3 gets an exclusive-lock on Y;
T1 blocks waiting for an exclusive-lock on Y;
T3 finishes, commits and releases locks;
T1 wakes up, get an exclusive-lock on Y, finishes up and releases lock on X and Y;
T2 now gets both an exclusive-lock on X and Y, and proceeds to finish. No deadlock.