Вы находитесь на странице: 1из 2

Database Management Systems Practice Problem Set: Transaction and Concurrency Control

1. Consider the following two transactions: T1 : read(A); read(B); if A = 0 then B := B + 1; write(B). T2 : read(B); read(A); if B = 0 then A := A + 1; write(A). Let the consistenc re!"ire#ent $e A = 0 B = 0% with A = B = 0 the initial &al"es. a. 'how that e&er serial e(ec"tion in&ol&ing these two transactions )reser&es the consistenc of the data$ase. $. 'how a conc"rrent e(ec"tion of T1 and T2 that )rod"ces a nonseriali*a$le sched"le. c. +s there a conc"rrent e(ec"tion of T1 and T2 that )rod"ces a seriali*a$le sched"le, 2. -nd all &iew.e!"i&alent serial orders for the following sched"le: r1 (/) r0 (T ) w1 (1 ) r2 (1 ) w0 (1 ) r2 (1 ) w2 (3) r4 (3) w2 (') r4 (') w4 (1 ) 0. Consider the following two transactions: T1 = w1 (3) r1 (/) w1 (/) r1 (1 ) w1 (1 ) T2 = r2 (1 ) w2 (1 ) r2 (/) w2 (/) Let "s ass"#e that o"r sched"ler )erfor#s e(cl"si&e loc5ing onl (i.e.% no shared loc5s). Consider the following instances of transactions T1 and T2 annotated with loc5% "nloc5% and (so#eti#es) co##it actions: (a) T1 = L1 (3) w1 (3) L1 (/) r1 (/) w1 (/) 61 (/) L1 (1 ) r1 (1 ) w1 (1 ) 61 (3) 61 (1 ) T2 = L2 (1 ) r2 (1 ) w2 (1 ) 62 (1 ) L2 (/) r2 (/) w2 (/) 62 (/) ($) T1 = L1 (3) w1 (3) L1 (/) r1 (/) w1 (/) L1 (1 ) r1 (1 ) w1 (1 ) C1 61 (/) 61 (3) 61 (1 ) T2 = L2 (1 ) r2 (1 ) w2 (1 ) L2 (/) r2 (/) w2 (/) C2 62 (/) 62 (1 ) (c) T1 = L1 (3) L1 (/) w1 (3) r1 (/) w1 (/) L1 (1 ) r1 (1 ) w1 (1 ) C1 61 (/) 61 (3) 61 (1 ) T2 = L2 (1 ) r2 (1 ) w2 (1 ) L2 (/) r2 (/) w2 (/) C2 62 (/) 62 (1 ) (d) T1 = L1 (1 ) L1 (3) w1 (3) L1 (/) r1 (/) w1 (/) r1 (1 ) w1 (1 ) C1 61 (/) 61 (3) 61 (1 ) T2 = L2 (1 ) r2 (1 ) w2 (1 ) L2 (/) r2 (/) w2 (/) C2 62 (/) 62 (1 ) -or each instance% indicate whether the annotated transactions satisf the following conditions: (1) 7$e two.)hase loc5ing. (2) 7$e strict two.)hase loc5ing. (0) 8ill necessaril res"lt in a con9ict seriali*a$le sched"le (if no deadloc5 occ"rs). (2) 8ill necessaril res"lt in a reco&era$le sched"le (if no deadloc5 occ"rs). (4) 8ill necessaril res"lt in a sched"le that a&oids cascading roll$ac5s (if no deadloc5 occ"rs). (:) 8ill necessaril res"lt in a strict sched"le (if no deadloc5 occ"rs). (;) 8ill necessaril res"lt in a serial sched"le (if no deadloc5 occ"rs). (<) =a res"lt in a deadloc5.

2. 'how that there are sched"les that are )ossi$le "nder the two.)hase loc5ing )rotocol% $"t are not )ossi$le "nder the ti#esta#) )rotocol% and &ice &ersa. 4. Consider a &ariant of the tree )rotocol called the forest )rotocol. The data$ase is organi*ed as a forest of rooted trees. >ach transaction Ti #"st follow the following r"les: ? The @rst loc5 in each tree #a $e on an data ite#. ? The second% and all s"$se!"ent% loc5s in a tree #a $e re!"ested onl i the )arent of the re!"ested node is c"rrentl loc5ed. ? Aata ite#s #a $e "nloc5ed at an ti#e. ? A data ite# #a not $e reloc5ed $ Ti after it has $een "nloc5ed $ Ti. 'how that the forest )rotocol does not ens"re seriali*a$ilit .

Вам также может понравиться