Theoremcore
Serializability theorem
Also called precedence graph test for conflict serializability.
A schedule is conflict serializable exactly when its conflict graph is acyclic, and a topological order gives an equivalent serial order.
The serializability theorem says that the committed work of a schedule can be reordered into a serial schedule, by moves that keep every conflict, exactly when its serialization graph has no cycle. The serial orders that work are then exactly the topological orders of the graph. Eswaran, Gray, Lorie and Traiger stated it in 1976; Bernstein, Hadzilacos and Goodman gave it its name in their 1987 book, in the form with commits and aborts that is used here. It turns conflict serializability into a graph question that takes polynomial time, while the more permissive view serializability is NP-complete to test.
Statement
Let be a schedule over with read, write, commit and abort actions, and let be its committed projection: the actions of the transactions that have committed in . Two actions conflict if they belong to different transactions, touch the same item, and at least one is a write.
The serialization graph has one node for each committed transaction, and an arc () if some action of in conflicts with a later action of in . (This is the conflict graph of .)
Theorem (serializability theorem). For every schedule :
- is conflict equivalent to a serial schedule if and only if is acyclic.
- A serial schedule of the committed transactions is conflict equivalent to if and only if is a topological order of .
- can be built, and tested for a cycle, in time for a schedule of actions.
In plain words
Draw an arrow from one transaction to another whenever the first touched an item before the second, and one of the two touches was a write. Such a pair can never be swapped without changing what some transaction reads or what the database holds at the end, so any serial order that works has to follow every arrow. If the arrows go round in a circle, no order can follow them all. If they do not, sort the transactions so that every arrow points forward, and that order works.
Proof
Write and . Part 2 implies part 1, because a directed graph has a topological order if and only if it is acyclic (the topological ordering theorem). The conflict serializability page proves part 2 by comparing conflicting pairs directly. Here is a second proof that builds the serial schedule by swaps, in the same way as Kahn's algorithm builds a topological order. It uses the swap lemma from that page: two schedules are conflict equivalent if and only if one can be turned into the other by swapping adjacent actions of different transactions that do not conflict.
Every equivalent serial order is a topological order. Let be serial in the order and conflict equivalent to . For an arc of there are conflicting and with , so , so comes before in .
Every topological order gives an equivalent serial schedule. We show by induction on the number of committed transactions: if is a topological order of , then can be turned into the serial schedule in the order by allowed swaps. For , is already serial.
Let and . Since is a topological order, has no incoming arc. Take the actions of from first to last, and move each one to the left by adjacent swaps until it stands right after the actions of that are already at the front. An action that the action of passes in this way comes before in and is not an action of . If conflicted with , would have the arc from the transaction of to , which does not exist. So each swap is allowed. The result is , where is without the actions of , in their old order.
The conflict graph of is without the node , because removing actions does not change the order of the others. So is a topological order of it, and by induction can be turned into the serial schedule by allowed swaps. The same swaps work in behind the block of . By the swap lemma the final serial schedule is conflict equivalent to .
Part 3. has at most actions. Compare every pair of positions, which takes time and gives at most arcs; then a depth-first search finds a cycle or a topological order in time linear in the size of the graph.
Worked example. . The conflicts are , which gives , and , which gives . The graph is the path , with the single topological order . The proof first moves to the front, past , and then right behind it, past , , and ; a commit conflicts with nothing. Then comes next: is already in place, and and move past , which touches another item. The result is , and no other serial order is conflict equivalent to .
Consequences
- Testing is easy. Conflict serializability can be decided in polynomial time. Practical schedulers do not build the graph for every schedule; they use protocols whose output is acyclic by design.
- The protocol theorems. The two-phase locking theorem is proved by showing that every arc of points from the earlier to the later lock point. Timestamp ordering makes every arc point from the smaller to the larger timestamp, and commitment ordering from the earlier to the later commit. Each then gets acyclicity for free.
- Prefix closure. If is a prefix of , then every transaction committed in is committed in , and every conflict of is a conflict of . So is a subgraph of , and conflict serializability of the committed projection is prefix closed.
- A scheduler must also watch active transactions. In , the graph has the single node . But if commits, the arcs and appear. A serialization graph testing scheduler therefore keeps the graph over all transactions that have not aborted, and refuses or aborts an action that would close a cycle.
- Aborts remove arcs. has a cycle between and among all actions, but aborted, and is the single node . The theorem says nothing about whether that abort was safe; that is the job of the recovery classes.
Tightness
- Only conflict equivalence. Acyclicity is necessary for conflict serializability, not for serializability in general. has the cycle , but it is view equivalent to : the blind write hides the order of the other two writes. For view serializability the graph is replaced by a polygraph with choice arcs, and the test becomes NP-complete.
- Only the read-write model. The theorem treats every pair of accesses with a write as a conflict. With operations that commute, such as increments, a cycle in the read-write graph can still allow a serial order. Semantic concurrency control uses a smaller conflict relation, and the theorem holds for that relation with the same proof.
- The bound in part 3 is for the plain method. The number of conflicting pairs can be quadratic in , but it is enough to keep, for each item, the last writer and the readers since that write; this gives arcs and a test in time linear in up to hashing.
History
Eswaran, Gray, Lorie and Traiger (1976) modeled a schedule as a sequence of actions, defined its dependency graph, and proved that a schedule is consistent (equivalent to a serial one) when the graph has no cycle; their paper used this to prove that two-phase transactions are safe. Papadimitriou (1979) compared this notion with broader ones and showed that they are harder to test. Bernstein, Hadzilacos and Goodman (1987) put the theorem in its present form over committed projections and called it the Serializability Theorem.
References
- Philip A. Bernstein, Vassos Hadzilacos and Nathan Goodman, Concurrency Control and Recovery in Database Systems, Addison-Wesley, 1987, Chapter 2 (the serialization graph of a history over its committed transactions, and the Serializability Theorem)
- K. P. Eswaran, J. N. Gray, R. A. Lorie and I. L. Traiger, The notions of consistency and predicate locks in a database system, Communications of the ACM 19(11), 1976, pages 624 to 633, the dependency graph of a schedule and the theorem that a schedule is equivalent to a serial one when the graph has no cycle
- Christos H. Papadimitriou, The serializability of concurrent database updates, Journal of the ACM 26(4), 1979, pages 631 to 653, the comparison of the conflict based test with other notions of serializability
- Gerhard Weikum and Gottfried Vossen, Transactional Information Systems, Morgan Kaufmann, 2001, Chapter 3 (conflict serializability and the conflict graph test)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag YM4CC5 Edit this page History Report an error Markdown