Professional Documents
Culture Documents
6-Review of DBMS Techniques - Serializability-10-01-2024
6-Review of DBMS Techniques - Serializability-10-01-2024
6-Review of DBMS Techniques - Serializability-10-01-2024
T1 T2
Read (A)
Write (A)
Read (B)
Read (A)
Write (B)
Write (A)
Read (B)
Write (B)
Schedule 8
• Swap the write(B) instruction of T1 with the read(A) instruction of
T2.
• A serial schedule that is equivalent to schedule 3.
• we have shown that schedule 3 is equivalent to a serial schedule.
• So, schedule 3 is conflict equivalent Schedule
T1 T2
Read (A)
Write (A)
Read (B)
Write (B)
Read (A)
Write (A)
Read (B)
Write (B)
Conflict Serializability (Cont.)
• If a schedule S can be transformed into a schedule S´ by a series
of swaps of non-conflicting instructions, we say that S and S´ are
conflict equivalent.
• The concept of conflict equivalence leads to the concept of
conflict serializability. We say that a schedule S is conflict
serializable if it is conflict equivalent to a serial schedule
Example for “not conflict serializable” (Sche: 9)
• Example of a schedule that is not conflict serializable:
y
• The set of vertices consists of all the transactions participating
in the schedule.
• The set of edges consists of all edges Ti →Tj for which one of
three conditions holds:
1. Ti executes write(Q) before Tj executes read(Q).
2. Ti executes read(Q) before Tj executes write(Q).
3. Ti executes write(Q) before Tj executes write(Q).
Precedence graph - Example 1
Precedence graph - Example 2
From T2 to T1 ---All 3
conditions are violated. So,
we can not draw T2 T1
Test for Conflict Serializability
• If the precedence graph for schedule S has a cycle, then the
schedule is not a conflict serializable.
• If the graph contains no cycles, then the schedule S is conflict
serializable.
• If precedence graph is acyclic, the serializability order can be
obtained by a topological sorting of the graph. This is a linear
order consistent with the partial order of the graph.
Illustration of topological sorting
• Thus, to test for conflict serializability, we need to construct
the precedence graph and to invoke a cycle-detection
algorithm.
• Cycle-detection algorithms exist which take order n2 time,
where n is the number of vertices in the graph. (Better
algorithms take order n + e where e is the number of edges.)
Schedule 10 – Special case
A = 1000
A = 1000 – 50
A = 950
B = 2000
B = 2000 - 10
B = 1990
B = 1990
B = 1990 + 50
B = 2040
A = 950
A = 950 + 10
A = 960
Schedule 10 – Serial Schedule
T1 T2 A = 1000
Read (A) A = 1000 – 50
A = A – 50 A = 950
Write (A)
B = 2000
Read (B)
B = B +50
B = 2000 + 50
Write (B)
B = 2050
Read (B)
B = 2020
B = B - 10 B = 2050 – 10
Write (B) B = 2040
Read (A) A = 950
A = A + 10 A = 950 + 10
Write (A) A = 960
1. Ti executes write(Q) before Tj
executes read(Q).
2. Ti executes read(Q) before Tj
executes write(Q).
3. Ti executes write(Q) before Tj
executes write(Q).
Schedule 12
cont.
• Cascadeless schedules — Cascading rollback is undesirable,
since it leads to the undoing of a significant amount of work.
• It is desirable to restrict the schedules to those where cascading
rollbacks cannot occur. Such schedules are called cascadeless
schedules.
• Formally, a cascadeless schedule is one where, for each pair of
transactions Ti and Tj such that Tj reads a data item previously
written by Ti , the commit operation of Ti appears before the
read operation of Tj .
• It is easy to verify that every cascadeless schedule is also
recoverable.