Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conflict-Serializability (section 18.2 of Concurrency Control) - Amith KC Student ID – 006498310.

Similar presentations


Presentation on theme: "Conflict-Serializability (section 18.2 of Concurrency Control) - Amith KC Student ID – 006498310."— Presentation transcript:

1 Conflict-Serializability (section 18.2 of Concurrency Control) - Amith KC Student ID – 006498310

2 Overview One of the sufficient conditions to assure that a schedule is serializable is “ conflict-serializability ”. Idea of Conflicts. –Conflicting and non-conflicting actions. –Conflict-equivalent and conflict-serializability schedules. Precedence Graphs –Definition. –Test for conflict-serializability.

3 Conflicts Definition –is a pair of consecutive actions in a schedule such that, if their order is interchanged, then the behavior of at least one of the transactions involved can change. Non-conflicting actions: Let T i and T j be two different transactions (i ≠ j), then: –r i (X); r j (Y) is never a conflict, even if X = Y. The reason is that neither of these steps change the value of any database element. –r i (X); w j (Y) is not a conflict provided X ≠ Y. –w i (X); r j (Y) is not a conflict provided X ≠ Y. –Similarly, w i (X); w j (Y) is also not a conflict, provided X ≠ Y.

4 continued… Three situations of conflicting actions (where we may not swap their order) –Two actions of the same transaction. e.g., r i (X);w i (Y) –Two writes of the same database element by different transactions. e.g., w i (X);w j (X) –A read and a write of the same database element by different transactions. e.g., r i (X);w j (X) To summarize, any two actions of different transactions may be swapped unless: –They involve the same database element, and –At least one of them is a write operation.

5 Conflict-equivalent schedules: –Two schedules are called conflict-equivalent schedules if they can be turned one into the other by a sequence of non-conflicting swaps of adjacent actions. Conflict-serializability schedule: –A schedule is conflict-serializable if it is conflict-equivalent to a serial schedule. Conflict Serializability is not required for a schedule to be serializable, but it is the condition that the schedulers in commercial systems generally use when they need to guarantee serializablity. continued…

6 Precedence Graphs Conflicting pairs of actions (of a schedule S) put constraints on the order of transactions in the hypothetical, conflict-equivalent serial schedule. For a schedule S, involving transactions T 1 and T 2 (among other transactions), we say that T 1 takes precedence over T 2 (written as T 1 < s T 2 )if there are actions A 1 of T 1 and A 2 of T 2, such that: –A 1 is ahead of A 2 in S, –Both A 1 and A 2 involve the same database element, and –At least one of them is a write operation.

7 continued… The precedences mentioned in the previous slide can be depicted in a “ precedence graph”. The nodes in this graph are the transactions of the schedule S. Example of a precedence graph: –Consider a schedule S which involves three transactions T 1, T 2 and T 3, i.e., S: r 2 (A); r 1 (B); w 2 (A); r 3 (A); w 1 (B); w 3 (A); r 2 (B); w 2 (B); The precedence graph for this as is shown below: 1 2 3 Figure 1

8 Test for conflict-serializability Construct the precedence graph for S and observe if there are any cycles. –If yes, then S is not conflict-serializable –Else, it is a conflict-serializable schedule. Example of a cyclic precedence graph: –Consider the below schedule S 1 : r 2 (A); r 1 (B); w 2 (A); r 2 (B); r 3 (A); w 1 (B); w 3 (A); w 2 (B); The precedence graph for this as shown below: 1 2 3 Figure 2

9 continued… Observing the actions of A in the previous example (figure 2), we can find that T 2 <s 1 T 3. But when we observe B, we get both T 1 <s 1 T 2 and T 2 <s 1 T 1. Thus the graph has a cycle between 1 and 2. So, based on this fact we can conclude that S 1 is not conflict-serializable.

10 Why the Precedence-Graph test works A cycle in the graph puts too many constraints on the order of transactions in a hypothetical conflict-equivalent serial schedule. If there is a cycle involving n transactions T 1 T 2..T n T 1 –Then in the hypothetical serial order, the actions of T 1 must precede those of T 2 which would precede those of T 3... up to n. –But actions of T n are also required to precede those of T 1. –So, if there is a cycle in the graph, then we can conclude that the schedule is not conflict-serializable.

11 Thank you!


Download ppt "Conflict-Serializability (section 18.2 of Concurrency Control) - Amith KC Student ID – 006498310."

Similar presentations


Ads by Google