Kyoung-Hwan Yun (#110) Conflicts Precedence Graphs and a Test for Conflict- Serializability 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 Non-conflicting situations: ri(X); rj(Y) will never conflict, even if X = 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. Three situations where actions may not be swapped: Two actions of the same transactions always conflict ri(X); wi(Y) Three situations where actions may not be swapped: Two writes of the same database element by different transactions conflict wi(X); wj(X) Three situations where actions may not be swapped: A read and a write of the same database element by different transaction conflict ri(X); wj(X) wi(X); rj(X) Two actions of different transactions may be swapped unless: They involve the same database element, AND At least one is a write. 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. 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); 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 graph: Nodes represent transactions of S Arc from node i to node j if Ti <S Tj Example Schedule Precedence Graph S: r2(A); r1(B); w2(A); r3(A); w1(B); w3(A); r2(B); w2(B); T1 Acyclic Conflict-serializable T2 T3 Example Schedule Precedence Graph S: r2(A); r1(B); w2(A); r2(B); r3(A); w1(B); w3(A); w2(B); T1 Cyclic Not conflict-serializable T2 T3 A schedule is conflict-serializable if and only if its precedence graph is acyclic.