【正文】
iven the other locks that may already be held. ? A patibility matrix has a row and column for each lock mode. ? Row corresponds to a lock that is already held on an element X by another transaction. ? Columns corresponds to the mode of a lock on X that is requested. The patibility matrix for shared and exclusive locks Lock requested Lock held Upgrading Locks ? Transactions T takes a shared lock on X, other transactions also allowed to read X at same time. ? Transaction T request for exclusive lock on X. ? ui (x) releases all locks on x held by transaction Ti. T1 T2 sl1 (A)。 r1 (A)。 sl2 (A)。 r2 (A)。 sl2 (B)。 r2 (B)。 sl1 (B)。 r1 (B)。 xl1 (B) Denied u2 (A)。 u2 (B)。 xl1 (B)。 w1 (B)。 u1 (A)。 u2 (B)。 Upgrading locks allow more concurrent operation Upgrading by two transactions can cause a deadlock Upgrading Locks – Ex. T1 T2 sl1 (A)。 sl2 (A)。 xl1 (A) Denied xl2 (A) Denied Update Locks ? Deadlock problem can be avoided by using update lock. ? Update lock uli (x), only read x but not write x. ? Update lock can be upgraded to write loack. Compatibility matrix for shared, exclusive and update locks. S X U S Yes No Yes X No No No U No No No Collect execution using update locks Update Locks – Ex. T1 T2 ul1 (A)。 r1 (A)。 ul2 (A) Denied xl1 (A)。 w1(A)。 u1(A)。 ul2(A)。 r2 (A)。 xl2(A)。 w2(A)。 u2(A)。 Increment Locks ? Many transactions operate by increment or decrement. Fund transfer, airline tickets ? Increment actions mute with each other. S X I S Yes No No X No No No I No No Yes Tran Mode Wait? Nxt Tnext T1 S no T2 U no T3 X yes ? To other T3 records A Group Mode : U Waiting : yes List : Element Info Lock Table What are the objects we lock? Relation A Relation B ... Tuple A Tuple B Tuple C ... Disk block A Disk block B ... DB DB DB Example R1 tu1 tu2 tu3 tu4 T1(IS) T1(S) , T2(S) Root Relation Tuples Example R1 tu1 tu2 tu3 tu4 T1(IS) T1(S) , T2(IX) T2(X) Root Relation Tuples Multiple granularity Requestor IS IX S X IS Holder IX S X T T T F F F F F F F T F T F T T