Algorithm Search⌘K

Techniqueadvanced

Commitment ordering

Also called commit ordering, commitment order, CO.

Commit transactions in the order of their conflicts. Each local schedule is then serializable, and with atomic commitment the global schedule across databases is too.

Commitment ordering (CO), named by Raz in 1992, is the rule that a scheduler commits transactions in the same order as their conflicts: if an operation of TiT_i comes before a conflicting operation of TjT_j and both commit, then TiT_i commits first. The commit order is then a topological order of the conflict graph, so the schedule is conflict serializable, with the commit order as a serial order. The rule needs no information from other sites. If every database of a distributed system enforces it locally and the sites decide commits with atomic commitment, such as two-phase commit, then the global schedule is serializable too. That is the use Raz had in mind: global serializability over autonomous databases that may use different concurrency control methods. Strict two-phase locking in its strong form, where all locks are held to the end, always gives CO schedules.

In plain words

When two transactions touch the same data, one of them goes first. Commitment ordering asks that the one that went first also commits first. If every pair follows this rule, the order of commits is an order in which the transactions could have run one at a time, so the result is correct. The rule is cheap to enforce, because a database only has to look at its own conflicts and at the order in which it commits. When a transaction is ready to commit, the database aborts the transactions that touched the same data before it and are still undecided, or makes it wait for them. Because the rule uses only the commit order, many databases can each follow it on their own and the whole system stays correct, as long as they agree on which transactions commit.

When it applies

  • A scheduler that already produces conflict serializable schedules, and that can delay or abort a commit. CO adds a check at commit time.
  • Several resource managers that take part in one atomic commitment protocol, and that must give a globally serializable result without exchanging conflict information or a global timestamp.
  • Systems that want the commit order to be a serial order, so that clients that see commits in real time see a serial order. Every schedule that is CO is order-preserving: a transaction that commits before another starts comes first in the serial order.

The template

The scheduler keeps the conflict graph of the transactions that are not yet decided, together with the committed ones that still have undecided successors. The holes are the local concurrency control ⟨LOCAL-CC⟩ and the choice ⟨POLICY⟩ between aborting and waiting.

  1. ON-OPERATION(T, op)
  2. 1run op under ⟨LOCAL-CC⟩ ▷ any method, or none
  3. 2for each earlier operation op' of an undecided or committed T' ≠ T that conflicts with op do add T' → T to G
  4. READY-TO-COMMIT(T) ▷ T has finished and votes, or asks to commit
  5. 3A ← the undecided transactions with a path to T in G ▷ the abort set of T
  6. 4if ⟨POLICY⟩ = abort then abort every transaction in A
  7. 5else wait until every transaction in A has committed or aborted
  8. 6commit T (or vote yes on T in atomic commitment)
  9. 7remove T and the aborted transactions from G when they have no undecided predecessor

Why a schedule of this template is serializable. A committed transaction never has an undecided predecessor at its commit: line L4 or L5 removed it. So for each arc Ti→TjT_i \to T_j between committed transactions, TiT_i committed before TjT_j. All arcs go forward in the commit order, the graph of committed transactions is acyclic, and the commit order is a serial order by the serializability theorem.

Why the global schedule is serializable. Let each site run the template and vote yes on TT only at line L6. Suppose the global conflict graph has a cycle T1→T2→⋯→Tk→T1T_1 \to T_2 \to \cdots \to T_k \to T_1 of committed transactions, where the arc Tl→Tl+1T_l \to T_{l+1} comes from a conflict at some site SlS_l. At SlS_l, Tl+1T_{l+1} got its yes vote only after TlT_l was decided there, and TlT_l is decided at a site only after the global decision on TlT_l. So the global decision on TlT_l comes before the global decision on Tl+1T_{l+1}, for every ll, which around the cycle is impossible. The atomic commitment protocol does the work of a global coordinator, and no site needs to know the conflicts of another.

Classes. CO schedules are conflict serializable; they are a strict subclass of the order-preserving conflict serializable schedules. r1(x) w2(x) c2 c1r_1(x)\, w_2(x)\, c_2\, c_1 is serializable as T1T2T_1 T_2 and order-preserving, but not CO, because T2T_2 commits first. Rigorous schedules, in which no item that TiT_i has read or written is written or read in conflict by another transaction until TiT_i ends, are CO: a conflict pi<qjp_i < q_j gives ci<qj<cjc_i < q_j < c_j.

Classic examples

  • Strong strict two-phase locking. Under strict two-phase locking with read locks also held to the end, a conflicting operation of TjT_j waits until TiT_i has ended. The schedule is rigorous, so it is CO, and its commits need no extra check. This is why distributed databases built on locks and two-phase commit are globally serializable.
  • Optimistic and timestamp schedulers. A method that does not hold locks, such as optimistic concurrency control or timestamp ordering, can be made CO by the check of lines L3 to L5 at commit. Raz proposed CO for such resource managers in a mixed system.
  • Multidatabases. In a federation of autonomous databases, each with its own concurrency control and with no global timestamp, CO at each database and a common atomic commitment protocol give global serializability. The participants exchange only commit votes.
  • A small run. w1(x) r2(x) w2(y)w_1(x)\, r_2(x)\, w_2(y), and T2T_2 is ready first. Its abort set is {T1}\{T_1\}. With the abort policy, T1T_1 is aborted and T2T_2 commits; but T2T_2 read the value of T1T_1, so the schedule is not recoverable, and a scheduler that must also be recoverable has to abort T2T_2 as well. With the wait policy, T2T_2 waits for T1T_1, which commits; then T2T_2 commits after it.

Variations

  • Abort or wait. The abort policy never blocks a commit but may abort much work; the wait policy aborts nothing that would have committed but makes a ready transaction wait for slower ones, and in atomic commitment it delays the vote.
  • Extended CO. In later work Raz gave a weaker rule that orders only conflicts between global transactions, for systems with local transactions that do not take part in atomic commitment. Local transactions still follow the local concurrency control.
  • Commit order and real time. Since the commit order is a serial order, a system that also reports commits in that order gives a form of external consistency for its clients.
  • Strict CO. Combining CO with a strict schedule makes recovery by before-images correct as well.

Pitfalls

  • CO is not recoverability. CO speaks only about pairs of transactions that both commit. If T2T_2 reads from T1T_1, T2T_2 commits and T1T_1 then aborts, the schedule is CO but not recoverable. The abort policy of line L4 produces exactly this case, so recoverability must be enforced as well.
  • Abort sets can cascade. Under the abort policy, aborting the predecessors of a ready transaction can abort a transaction that others have read from, and their aborts follow.
  • Local CO without atomic commitment is not enough. The global argument uses the fact that a site votes yes only after the predecessors are decided globally. If sites commit on their own, each local schedule is serializable but the serial orders of two sites can disagree.
  • Voting yes too early. A site that votes yes on TT while a local predecessor of TT is still undecided breaks the proof, even if it later commits in the right order.

Exercises

  1. Show that a CO schedule is order-preserving: if TiT_i commits before TjT_j starts, then TiT_i is before TjT_j in some serial order of the schedule.
  2. Give a conflict serializable schedule of three transactions that is not CO, and give the commit order that would make it CO.
  3. Two sites run strong strict two-phase locking and decide commits by two-phase commit. Show directly, without CO, that the global schedule is serializable.
  4. In the template, why must line L3 use paths in GG and not only direct predecessors? Give a schedule where only a path reaches TT.
  5. Site 1 runs CO and site 2 runs ordinary strict two-phase locking with read locks released at the end of the transaction's work, before commit. Give a global schedule that is not serializable.

References

  1. Yoav Raz, The principle of commitment ordering, or guaranteeing serializability in a heterogeneous environment of multiple autonomous resource managers using atomic commitment, Proceedings of the 18th VLDB Conference, 1992, pages 292 to 312, the definition of commitment ordering, the proof that CO implies serializability, the commitment ordering algorithm with its abort set, and global serializability under atomic commitment
  2. Gerhard Weikum and Gottfried Vossen, Transactional Information Systems, Morgan Kaufmann, 2001, Chapter 3, the classes of order-preserving and commit order-preserving conflict serializable schedules, chapter level only
  3. Philip A. Bernstein, Vassos Hadzilacos and Nathan Goodman, Concurrency Control and Recovery in Database Systems, Addison-Wesley, 1987, Chapter 2 (the serializability theorem and the conflict graph) and Chapter 7 (atomic commitment), chapter level only

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • five exercises