A precedence graph, also named conflict graph[1] and serializability graph, is used in the context of concurrency control in databases.[2] It is the directed graph representing precedence of transactions in the schedule, as reflected by precedence of conflicting operations in the transactions. A schedule is conflict-serializable if and only if its precedence graph of committed transactions is acyclic.

The precedence graph for a schedule S contains:

  • A node for each committed transaction in S
  • An arc from Ti to Tj if an action of Ti precedes and conflicts with one of Tj's actions. That is the actions belong to different transactions, at least one of the actions is a write operation, and the actions access the same object (read or write).

Cycles of committed transactions can be prevented by aborting an undecided (neither committed, nor aborted) transaction on each cycle in the precedence graph of all the transactions, which can otherwise turn into a cycle of committed transactions (and a committed transaction cannot be aborted). One transaction aborted per cycle is both required and sufficient in number to break and eliminate the cycle (more aborts are possible, and can happen under some mechanisms, but are unnecessary for serializability). The probability of cycle generation is typically low, but, nevertheless, such a situation is carefully handled, typically with a considerable amount of overhead, since correctness is involved. Transactions aborted due to serializability violation prevention are restarted and executed again immediately.

Precedence graph examples

edit

Example 1

edit

Example 2

edit

A precedence graph of the schedule D, with 3 transactions. As there is a cycle (of length 2; with two edges) through the committed transactions T1 and T2, this schedule (history) is not Conflict serializable. Notice, that the commit of Transaction 2 does not have any meaning regarding the creation of a precedence graph.

Example 3

edit
Testing Serializability Example

Algorithm to test Conflict Serializability of a Schedule S along with an example schedule.

or

  1. For each transaction Tx participating in schedule S, create a node labeled Ti in the precedence graph. Thus the precedence graph contains T1, T2, T3.
  2. For each case in S where Tj executes a read_item(X) after Ti executes a write_item(X), create an edge (Ti → Tj) in the precedence graph. This occurs nowhere in the above example, as there is no read after write.
  3. For each case in S where Tj executes a write_item(X) after Ti executes a read_item(X), create an edge (Ti → Tj) in the precedence graph. This results in a directed edge from T1 to T2 (as T1 has R(A) before T2 having W(A)).
  4. For each case in S where Tj executes a write_item(X) after Ti executes a write_item(X), create an edge (Ti → Tj) in the precedence graph. This results in directed edges from T2 to T1, T2 to T3 and T1 to T3.
  5. The schedule S is serializable if and only if the precedence graph has no cycles. As T1 and T2 constitute a cycle, the above example is not (conflict) serializable.

References

edit
  1. ^ "21-110: Conflict graphs".
  2. ^ "Precedence graph test for conflict-serializability".
edit

📚 Artikel Terkait di Wikipedia

Dependency graph

mathematics, computer science and digital electronics, a dependency graph is a directed graph representing dependencies of several objects towards each other

Wait-for graph

not materialized are not reflected in the precedence graph and do not affect serializability. The wait-for-graph scheme is not applicable to a resource allocation

Database transaction schedule

non-materialized; non-materialized conflicts are not represented by an edge in the precedence graph. The schedules S1 and S2 are said to be conflict-equivalent if and

Topological sorting

By definition, the solution of a scheduling problem that includes a precedence graph is a valid solution to topological sort (irrespective of the number

Concurrency control

Serialization graph checking (also called Serializability, or Conflict, or Precedence graph checking) - Checking for cycles in the schedule's graph and breaking

Flix (programming language)

because the last expression constructs a Datalog program value whose precedence graph contains a negative cycle: the Bachelor predicate negatively depends

Order of operations

operation is called its precedence, and an operation with a higher precedence is performed before operations with lower precedence. Calculators generally

Assembly line

of tasks to stations is typically limited by two constraints: (1) a precedence graph which indicates what other tasks need to be completed before a particular