Unit 5 Part 1
Unit 5 Part 1
Goonjan Jain
Dept. of Applied Mathematics
Delhi Technological University
Overview
• Transaction Overview
• Concurrency
• Recovery
Motivation
• Lost Updates Two people change the same record (Concurrency
control) (“Rajan”); how to avoid “race condition”?
S1 S2
T1 T2 T1 T2
A= A+2000 A = A *1.05
B = B-2000 B = B * 1.05
A = A *1.05 A= A+2000
B = B * 1.05 B = B-2000
Interleaving Transactions - Schedule
• Interleave the transactions in order to maximize concurrency.
• Slow disk/network I/O.
• Multi-core CPUs.
• Legal outcomes - A=12,600, B=8,400; A=12,500, B=8,500
S1 S2
T1 T2 T1 T2
A= A+2000 A= A+2000
A = A *1.05 A = A *1.05
B = B-2000 B = B * 1.05
B = B * 1.05 B = B-2000
Good Bad
Interleaving Transactions - Schedule
Schedule S DBMS View of Schedule
T1 T2 T1 T2
A= A+2000 R(A)
A = A *1.05 W(A)
B = B * 1.05 R(A)
B = B-2000 W(A)
R(B)
W(B)
R(B)
W(B)
Schedule
• Q: How would you judge that a schedule is ‘correct’?
• A: if it is equivalent to some serial execution