Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Databases System. The complete book. Exercise 18.4.1 For parts (a) and (c). of t

ID: 3824265 • Letter: D

Question

Databases System. The complete book. Exercise 18.4.1 For parts (a) and (c). of the schedules of transactions T1, T2, and T3 below:

a) r1 (A); r2 (B); r3(C); w1(B); w2 (C); w3(D);

c) r1(A); r2(B); r3 (C); r1(B); r2(C); r3 (D); w1 (C); w2 (D); w3 (E);

Question. Do each of the following:

i. Insert shared and exclusive locks, and insert unlock actions. Place a shared lock immediately in front of each read action that is not followed by a write action of the same element by the same transaction. Place an exclusive lock in front of every other read or write action. Place the necessary unlocks at the end of every transaction.

ii. Tell what happens when each schedule is run by a scheduler that supports shared and exclusive locks.

iii. Insert shared and exclusive locks in a way that allows upgrading. Place a shared lock in front of every read, an exclusive lock in front of every write, and place the necessary unlocks at the ends of the transactions.

iv. Tell what happens when each schedule from (iii) is run by a scheduler that supports shared locks, exclusive locks, and upgrading.

v. Insert shared, exclusive, and update locks, along with unlock actions. Place a shared lock in front of every read action that is not going to be upgraded, place an update lock in front of every read action that will be

upgraded, and place an exclusive lock in front of every write action. Place unlocks at the ends of transactions, as usual.

vi. Tell what happens when each schedule from (v) is run by a scheduler that supports shared, exclusive, and update locks.

Explanation / Answer

(iANS). //xl1(A); r1(A); xl2(B); r2(B); xl3(C); r3(C); sl1(B); r1(B); sl2(C); r2(C); sl3(D); r3(D); w1(A); u1(A); u1(B); w2(B); u2(B); u2(C); w3(C); u3(C); u3(D)//

(iiANS). The first 3 locks and reads are allowed. How_ever, 'T1' can'not get a "shared_lock" on 'B', nor it can 'T2' get a shared_lock on 'C'. Once 'T3' requests a shared lock on 'D' it's granted. Thus, 'T3' can proceed and eventually unlocks 'C' and 'D'.

-->As shortly as 'C' is unlocked, 'T2' will get its shared lock on 'C'. Thus, 'T2' completes and releases its locks. As sooon as it's lock on 'B' is released., 'T1' will get it's lock on 'A', thus it completes.

(iiiANS). //-- sl1(A); r1(A); sl2(B); r2(B); sl3(C); r3(C); sl1(B); r1(B); sl2(C); r2(C); sl3(D); r3(D); xl1(A); w1(A); u1(A); u1(B); xl2(B); w2(B); u2(B); u2(C); xl3(C); w3(C); u3(C); u3(D) --//

(ivANS). First., all 6 shared-lock requests are granted. when 'T1' requests an exclusive lock on 'A', it gets it, as a result of it's the only transaction holding a lock on 'A'. 'T1' completes and releases its locks. Thus, once 'T2' asks for an exclusive lock on 'B', it's the sole dealings still holding a shared lock on 'B', in order that lock too could also be granted, and 'T2' completes. whenn the 'T2' release's it's -locks, 'T3' is able to upgrde it's shared lock on 'C' to exclusive, and it too proceedss. The actions are so executed in exactly the same order as they're requestd., i.e., ''there are not any delays by the schedulerr''.

(vANS). ///-- ul1(A); r1(A); ul2(B); r2(B); ul3(C); r3(C); sl1(B); r1(B); sl2(C); r2(C); sl3(D); r3(D); xl1(A); w1(A); u1(A); u1(B); xl2(B); w2(B); u2(B); u2(C); xl3(C); w3(C); u3(C); u3(D) --///

(viANS). The update_locks preventt the 4th and 5th 'shared-lock' requests, 'sl1(B)' & 'sl2(C)', thus 'T1' and 'T2' are -delayed, where'as 'T3' is allowed to proceeed. The situation is 'exactly' as for -part--(ii), wherever the 'initial_lock' requests are for the 'exclusive_locks'.