Graphing Database Conflicts: How Precedence Graphs Prove Serializability
In high-throughput relational databases, executing transactions serially (one after another) wastes massive CPU and I/O parallelism. Instead, storage engines execute multiple transactions concurrently with interleaved operations.
However, arbitrary interleaving can trigger lost updates, dirty reads, and inconsistency.
To prove that an interleaved schedule S is mathematically safe, database theory relies on Conflict Serializability.
1. What Makes Two Operations Conflict?
Two operations I_i and I_j in a schedule conflict if and only if they satisfy three conditions:
- They belong to different transactions (
T_i ≠ T_j). - They access the same data item (
Q). - At least one of them is a write operation (
W(Q)).
The Conflict Matrix:
-
Read-Read (
R_i(Q), R_j(Q)): No conflict. Order does not alter data. -
Read-Write (
R_i(Q), W_j(Q)): Conflict. Swapping changes whetherT_ireads the old or new value. -
Write-Read (
W_i(Q), R_j(Q)): Conflict. Swapping altersT_j's observation. -
Write-Write (
W_i(Q), W_j(Q)): Conflict. Swapping alters the final value surviving in storage.
2. Constructing the Precedence Graph
A Precedence Graph (or Serialization Graph) is a directed graph G = (V, E) constructed as follows:
-
Vertices (
V): Every transaction participating in the schedule. -
Edges (
E): A directed edgeT_i → T_jis drawn ifT_iexecutes a conflicting operation beforeT_j.
3. The Serializability Theorem
A concurrent schedule
Sis conflict serializable if and only if its precedence graph contains no directed cycles.
- If Acyclic: The schedule can be serialized. The equivalent serial execution order is obtained via Topological Sorting of the DAG.
-
If a Cycle Exists: (e.g.,
T₁ → T₂ → T₁), it impliesT₁must precedeT₂, butT₂must also precedeT₁—a physical impossibility. The schedule is rejected or aborted.
Explore interactive conflict precedence graph analyzers at Binary Dose.
Top comments (0)