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 comes before a conflicting operation of and both commit, then 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.
ON-OPERATION(T, op)- 1
run op under ⟨LOCAL-CC⟩ ▷ any method, or none - 2
for each earlier operation op' of an undecided or committed T' ≠ T that conflicts with op do add T' → T to G READY-TO-COMMIT(T) ▷ T has finished and votes, or asks to commit- 3
A ← the undecided transactions with a path to T in G ▷ the abort set of T - 4
if ⟨POLICY⟩ = abort then abort every transaction in A - 5
else wait until every transaction in A has committed or aborted - 6
commit T (or vote yes on T in atomic commitment) - 7
remove 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 between committed transactions, committed before . 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 only at line L6. Suppose the global conflict graph has a cycle of committed transactions, where the arc comes from a conflict at some site . At , got its yes vote only after was decided there, and is decided at a site only after the global decision on . So the global decision on comes before the global decision on , for every , 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. is serializable as and order-preserving, but not CO, because commits first. Rigorous schedules, in which no item that has read or written is written or read in conflict by another transaction until ends, are CO: a conflict gives .
Classic examples
- Strong strict two-phase locking. Under strict two-phase locking with read locks also held to the end, a conflicting operation of waits until 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. , and is ready first. Its abort set is . With the abort policy, is aborted and commits; but read the value of , so the schedule is not recoverable, and a scheduler that must also be recoverable has to abort as well. With the wait policy, waits for , which commits; then 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 reads from , commits and 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 while a local predecessor of is still undecided breaks the proof, even if it later commits in the right order.
Exercises
- Show that a CO schedule is order-preserving: if commits before starts, then is before in some serial order of the schedule.
- Give a conflict serializable schedule of three transactions that is not CO, and give the commit order that would make it CO.
- 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.
- In the template, why must line L3 use paths in and not only direct predecessors? Give a schedule where only a path reaches .
- 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
- 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
- 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
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag 05N9RH Edit this page History Report an error Markdown