160 likes | 290 Views
18.2 Conflict- Serializability. Kyoung-Hwan Yun (#110). 18.2 Conflict- Serializability. Conflicts Precedence Graphs and a Test for Conflict- Serializability. Conflicts.
E N D
18.2 Conflict-Serializability Kyoung-Hwan Yun (#110)
18.2 Conflict-Serializability • Conflicts • Precedence Graphs and a Test for Conflict-Serializability
Conflicts • Conflict: a pair of consecutive actions in a schedule such that, if their order is interchanged, the final state produced by the schedule is changed
Conflicts • Non-conflicting situations: • ri(X); rj(Y) will never conflict, even ifX = Y. • ri(X); wi(Y) will not conflict for X ≠ Y. • wi(X); rj(Y) will not conflict for X ≠ Y. • wi(X); wj(Y) will not conflict for X ≠Y.
Conflicts • Three situations where actions may not be swapped: • Two actions of the same transactions always conflictri(X); wi(Y)
Conflicts • Three situations where actions may not be swapped: • Two writes of the same database element by different transactions conflictwi(X); wj(X)
Conflicts • Three situations where actions may not be swapped: • A read and a write of the same database element by different transaction conflictri(X); wj(X)wi(X); rj(X)
Conflicts • Two actions of different transactions may be swapped unless: • They involve the same database element, AND • At least one is a write.
Conflicts • The schedules S and S’are conflict-equivalent, if S can be transformed into S’by a sequence of non-conflicting swaps of adjacent actions. • A schedule is conflict-serializable if it is conflict-equivalent to a serial schedule.
Conflicts • Example of conflict-serializable schedule; schedule is converted to the serial schedule (T1,T2) through a sequence of swaps.r1(A); w1(A); r2(A); w2(A); r1(B); w1(B); r2(B); w2(B);r1(A); w1(A); r2(A); w2(A); r1(B); w1(B); r2(B); w2(B);r1(A); w1(A); r2(A); r1(B); w2(A); w1(B); r2(B); w2(B);r1(A); w1(A); r1(B); r2(A); w2(A); w1(B); r2(B); w2(B);r1(A); w1(A); r1(B); r2(A); w1(B); w2(A); r2(B); w2(B);r1(A); w1(A); r1(B); w1(B); r2(A); w2(A); r2(B); w2(B);
Precedence Graphs and a Test for Conflict-Serializability • Given a schedule S, involving transactions T1 and T2, T1 takes precedence over T2 (T1 <S T2), if there are actions A1 of T1 and A2 of T2, such that: • A1 is ahead of A2 in S, • Both A1 and A2 involve the same database element, and • At least one of A1 and A2 is a write action. • These are exactly the conditions under which we cannot swap the order of A1 and A2. Therefore, a conflict-equivalent serial schedule must have T1 before T2.
Precedence Graphs and a Test for Conflict-Serializability • Precedence graph: • Nodes represent transactions of S • Arc from node i to node j if Ti <STj
Precedence Graphs and a Test for Conflict-Serializability Acyclic Conflict-serializable Example Schedule S: r2(A); r1(B); w2(A); r3(A); w1(B); w3(A); r2(B); w2(B); Precedence Graph T1 T2 T3
Precedence Graphs and a Test for Conflict-Serializability Cyclic Not conflict-serializable Example Schedule S: r2(A); r1(B); w2(A); r2(B); r3(A); w1(B); w3(A); w2(B); Precedence Graph T1 T2 T3
Precedence Graphs and a Test for Conflict-Serializability A schedule is conflict-serializableif and only if its precedence graph is acyclic.