Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
• System crash
• Transaction error
• Errors detected by the transaction ( lack of data
required)
• Concurrency control enforcement (Violation of
rules)
• Disk failure
• Physical problems and catastrophes- fire, theft,
overwriting by mistake
Transaction and System Concepts
Sa: r1(X); r2(X); w1(X); r1 (Y); w2(X); C2 ; w1(Y); C1; (T2 is not
reading after T1 has updated)
Sb: r1(X); w1(X); r2(X); w2(X); C2; r1(Y); a1; ( we assume that
transaction T1 aborted after its read item (Y) operation)
Schedules and Recoverability
Two operations in a schedule are said to conflict
if they belong to different transactions, if they
access the same data item X and if one of the
two operations is a write_item (X).
A schedule S of n transactions T1, T2......Tn is
said to be a correct schedule if the following
conditions hold:
Schedules and Recoverability
• The operations in S are exactly those operations
in T1, T2....Tn, including a commit or abort
operation as the last operation for each
transaction in the schedule.
• For any pair of operations from the same
transaction Ti, their order of appearance in S is
the same as their order of appearance in Ti
• For any two conflicting operations one of the
two must occur before the other in the schedule.
Characterizing Schedules based on
Recoverability
Once a transaction T is committed, it should
never be necessary to rollback T. The
schedules that meet this criterion are called
recoverable schedules.
A schedule S is said to be recoverable if no
transaction T in S commits until all
transactions T’ that have written an item that
T reads have committed.
Characterizing Schedules based on
Recoverability
A transaction T is said to read from transaction
T’ in a schedule S if some item X is first written
by T’ and later read by T.
In the schedule S, T’ should not have aborted
before T reads item X, and there should be no
transactions that write X after T’ writes it and
before T reads it.
Characterizing Schedules based on
Recoverability
Sa is recoverable. But consider Sc
Sc: r1(X); w1(X); r2(X); r1(Y); w2(X); C2; a1;