





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Deadlocks in database systems, their causes, and various techniques for preventing, detecting, and recovering from deadlocks. Topics include the two-phase locking algorithm, serialization graphs, recoverability, and avoiding cascading aborts.
Typology: Slides
1 / 9
This page cannot be seen from the preview
Don't miss anything!






1/11/ 05 1
Transaction Processing
1/11/ 05 2
1.A Sim ple System M odel 2.Serializability Theory 3.Synchronization Requirem ents forRecoverability 4.Tw o-Phase Locking 5.Preserving Transaction H andshakes 6.Im plem enting Tw o-Phase Locking 7.D eadlocks
1/11/ 05 3
1/11/ 05 4
1/11/ 05 5
Transaction 1 Transaction N
Start, Commit, Abort Read(x), Write(x)
D ata M anager
D atabase
Transaction 2
1/11/ 05 6
1/11/ 05 7
Equivalence ofH istories
1/11/ 05 8
Exam ples ofEquivalence
1/11/ 05 9
Serializable H istories
H 1 = r 1 [x]r 2 [x]w 1 [x]c 1 w 2 [y]c 2 is equivalentto H 4 = r 2 [x]w 2 [y]c 2 r 1 [x]w 1 [x]c 1 (r 2 [x]and w 1 [x]are in the sam e orderin H 1 and H 4 .)
1/11/ 05 10
A notherExam ple
H 6 = r 1 [x]r 2 [x]w 1 [x]r 3 [x]w 2 [y]w 3 [x]c 3 w 1 [y]c 1 c 2 T2fi T (^1) T1fi T (^3) T 2 fi T (^1)
T 2 fi T (^3)
1/11/ 05 11
Serialization G raphs
H 6 = r 1 [x]r 2 [x]w 1 [x]r 3 [x]w 2 [y]w 3 [x]c 3 w 1 [y]c 1 c 2
SG(H 6 )= T 2 fi T 1 fi T (^3)
1/11/ 05 12
The Serializability Theorem A history is SR ifand only ifSG (H )is acyclic. Proof:(if)SG (H )is acyclic.So letH (^) s be a serial history consistentw ith SG (H ).Each pairof conflicting ops in H induces an edge in SG (H ). Since conflicting ops in H (^) s and H are in the sam e order,H (^) s”H ,so H is SR. (only if)H is SR.LetH (^) s be a serialhistory equivalent to H .W e claim thatifT (^) ifi Tk in SG (H ),then Ti precedes Tk in H (^) s (else H (^) s ≢ H ).IfSG (H )had a cycle,T 1 fi T 2 fi … fi T (^) nfi T 1 ,then T 1 precedes T 1 in H (^) s,a contradiction.So SG (H )is acyclic.
1/11/ 05 19
3.4 Tw o-Phase Locking
1/11/ 05 20
Basic Locking Isn’tEnough
rl 2 [y]r 2 [y]w l 2 [x]w 2 [x]ru 2 [y]w u 2 [x]c 2
1/11/ 05 21
Tw o-Phase Locking (2PL)Protocol
2PL Theorem :Ifalltransactions in an execution are tw o-phase locked,then the execution is SR. Proof:D efine T (^) i⇒ T (^) k ifeither
1/11/ 05 23
2PL and Recoverability
1/11/ 05 24
A utom ating Locking
1/11/ 05 25
T1: Start
... Display output Commit
T2: Start Get input from display
... Commit
U serreads output … U serenters input
Brain transport
1/11/ 05 27
Brain Transport(cont’d)
1/11/ 05 28
2PL Preserves Transaction H andshakes
1/11/ 05 29
2PL Preserves Transaction H andshakes (cont’d)
1/11/ 05 30
Brain Transport O ne LastTim e
1/11/ 05 37
Lock M anager(cont’d)
1/11/ 05 38
Locking G ranularity
1/11/ 05 39
M ultigranularity Locking (M G L)
3.7 D eadlocks
1/11/ 05 41
D eadlock Prevention
D eadlock D etection
1/11/ 05 43
D etection U sing W aits-ForG raph
1/11/ 05 44
D etection U sing W aits-ForG raph (cont’d)
1/11/ 05 45
Cyclic Restart
1/11/ 05 46
M S SQ L Server
1/11/ 05 47
D istributed Locking
1/11/ 05 48
D istributed D eadlock
rl 1 [x] w l 2 x
N ode 1 rl 2 [y] w l 1 y
N ode 2