Introduction To Transaction Processing Concepts and Theory
Introduction To Transaction Processing Concepts and Theory
Slide 17- 2
4 Characterizing Schedules based on
Recoverability (1)
Transaction schedule or history:
When transactions are executing concurrently in an interleaved
fashion, the order of execution of operations from the various
transactions forms what is known as a transaction schedule (or
history).
A schedule (or history) S of n transactions T1, T2, …,
Tn:
It is an ordering of the operations of the transactions subject to
the constraint that, for each transaction Ti that participates in
S, the operations of T1 in S must appear in the same order in
which they occur in T1.
Note, however, that operations from other transactions Tj can
be interleaved with the operations of Ti in S.
Slide 17- 3
Schedules and Recoverability
Two operations in a schedule are said to be in
conflict if
1. They belong to different transactions
2. They access the same data item X
3. At least one of the operations is write(X)
Example
Slide 17- 4
Example of a Schedule
Slide 17- 5
Schedules and Serializability
Complete schedule
A schedule S of n transactions T1, T2, …, Tn is said to be a
complete schedule if
1. The operations in S are exactly those operations in T1, T2,
…, Tn
2. 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
3. For any two conflicting operations, one of the two must
occur before the other in the schedule S
Slide 17- 6
Characterizing Schedules based on
Recoverability (2)
Schedules classified on recoverability:
Recoverable schedule:
One where no transaction needs to be rolled back.
r1(x);w1(x);r2(x);r1(y);w2(x);c2;a1;-Non recoverable;
Cascadeless schedule:
One where every transaction reads only the items that
Slide 17- 7
Characterizing Schedules based on
Recoverability (3)
Schedules classified on recoverability (contd.):
Schedules requiring cascaded rollback:
Slide 17- 8
5 Characterizing Schedules based on
Serializability (1)
Serial schedule:
A schedule S is serial if, for every transaction T
participating in the schedule, all the operations of
T are executed consecutively in the schedule.
Otherwise, the schedule is called nonserial
schedule.
Serializable schedule:
A schedule S is serializable if it is equivalent to
some serial schedule of the same n transactions.
Slide 17- 9
Serial Schedules
A B
T1: T2: T1: T2:
read_item(X); read_item(X);
X:= X - N; X:= X + M;
write_item(X); write_item(X);
read_item(Y); read_item(X);
Y:=Y + N; X:= X - N;
write_item(Y); write_item(X);
read_item(X); read_item(Y);
X:= X + M; Y:=Y + N;
write_item(X); write_item(Y);
Slide 17- 10
Non Serial Schedules
C D
T1: T2: T1: T2:
read_item(X); read_item(X);
X:= X - N; X:= X - N;
read_item(X); write_item(X);
X:= X + M; read_item(X);
write_item(X); X:= X + M;
read_item(Y); write_item(X);
write_item(X); read_item(Y);
Y:=Y + N; Y:=Y + N;
write_item(Y); write_item(Y);
Serializable schedule:
A schedule S is serializable if it is equivalent to some
serial schedule of the same n transactions.
Slide 17- 11
Strict schedule: A schedule is strict if it satisfies the
following conditions:
1) Tj reads a data item X after Ti has written to X and Ti is
terminated (aborted or committed)
2) Tj writes a data item X after Ti has written to X and Ti is
terminated (aborted or committed)
Cascadeless schedule: A schedule is cascadeless if the
following condition is satisfied:
Tj reads X only after Ti has written to X and terminated
(aborted or committed).
Identify the Strict schedules And Cascadeless
Schedules ???
S3: r1(x); r2(z); r1(z); r3(x); r3(y); w1(x); c1; w3(y); c3; r2(y);
w2(z); w2(y);c2
S4: r1(x); r2(z); r1(z); r3(x); r3(y); w1(x); w3(y); r2(y); w2(z);
w2(y); c1; c2; c3;
S5: r1(x); r2(z); r3(x); r1(z); r2(y); r3(y); w1(x); w2(z); w3(y);
w2(y); c3; c2;
Slide 17- 12