Conflict-Serializability Bharath Kumar Manur Venkataramana Class ID No:- 110
Conflicts What do you mean by a conflict in database? Example situation for such a conflict? Online Reservation Systems. 4 situations where conflict cannot happen 1) Ri (X) ; Rj (Y) will never conflict, even if database element X=Y. 2) Ri (X) ; Wi (Y) will not conflict for X not equal to Y. 3) Wi (X) ; Rj (Y) will not conflict for X not equal to Y. 4) Wi (X) ; Wj (Y) will not conflict for X not equal to Y.
Conflicts There are 3 situations where we may not swap the order of actions. They are:- 1) Two actions of the same transactions conflict. 2) Two writes of the same database element by different transactions conflict. 3) A read and a write of the same database element by different transactions also conflict.
Conflict Serializability Two actions conflict if:- 1) They are issued by different transactions. 2) They operate on the same database element. 3) At least one of them is a write operation. The 2 schedules S and S 1 are conflict-equivalent, if S can be transformed into S 1 by a sequence of non-conflicting swaps of adjacent actions. A schedule is conflict-serializable if it is conflict-equivalent to a serial schedule.
Conflict Serializability (Contd.) Schedule 1 can be transformed into Schedule 5, a serial schedule where T 2 follows T 1, by series of swaps of non-conflicting instructions. Therefore Schedule 1 is conflict serializable. Schedule 1Schedule 5
Precedence Graphs A Precedence graph is used to find out whether a schedule is conflict-serializable or not. There are 2 types of precedence graphs :- Acyclic Graphs which determines that the Schedule S is conflict-serializable. Cyclic Graphs which are nothing but the conflict graphs which cannot determine the precedence order for the Schedule S.
Algorithm to produce a Precedence Graph Add a node for each transaction. Add a directed edge from Ti to Tj, if Tj reads the value of a database element written by Ti. Add a directed edge from Ti to Tj, if Tj writes a value into the database element after it has been read by Ti. If the graph is cyclic, then the Schedule is not Conflict- Serializable.
Acyclic Graphs An example of a Schedule S. Example Schedule R 2 (a) R 1 (b) W 2 (a) R 3 (a) W 1 (b) W 3 (a) R 2 (b) W 2 (b) T3T1T2 Precedence Graph
Conflict or Cyclic Graphs An example of a Schedule S. Example Schedule W 1 (a) R 2 (a) R 3 (b) W 2 (c) R 3 (c) W 3 (a) W 3 (b) R 1 (b) Precedence Graph T1T2 T3 Execution is conflict-serializable only if the conflict graph is acyclic.
Test for Conflict-Serializability Let S be a schedule which consists of action of n transactions, T1 -> T2 -> T3 -> > Tn -> T1. The actions of T1 precedes T2 and so on till Tn, but since the action of Tn precedes T1. Due to Tn -> T1, we find there is a cycle in the precedence graph and the conclusion is that the schedule is not conflict-serializable. Finally a schedule is conflict serializable if and only if its precedence graph is acyclic.