Deterministic transaction ordering
Move agreement before execution while preserving access-set, replay, and nondeterminism assumptions.
On this page
The question for today
What you’ll understand
- Explain why agreeing on inputs before execution changes coordination.
- Identify nondeterministic inputs that replicas must not invent independently.
- Separate a planned serial order from unnecessary global serial execution.
Two transactions compete for a small remaining GPU quota. A conventional system may execute both and later coordinate conflicts. A deterministic design first agrees on the relevant transaction inputs and order, then arranges execution so replicas make the same decisions. The potential saving comes from moving and restructuring coordination, not from abolishing agreement or assuming that all programs naturally replay identically.
Agree on the work before acquiring its resources
Calvin’s design replicates an ordered transaction input stream and uses deterministic scheduling to avoid a conventional distributed commit agreement phase for its supported execution model. Participants can know which conflicting transaction should precede another before holding the transaction’s locks. This changes the contention footprint. It does not mean a partitioned machine can ignore the agreed plan, or that a node failure authorizes a new outcome. Recovery and replay must follow the same input and ordering commitments.
Execution need not be globally single-threaded. Nonconflicting transactions can overlap, and separate shards can perform their portions while preserving the required conflict order. Distinguish the order of logical effects from wall-clock instruction interleaving. If two transactions touch independent records, forcing one to finish entirely before the other starts can waste parallel capacity. The scheduler needs enough information to identify their accesses and coordinate dependencies, rather than granting unlimited parallelism and hoping the final outputs match.
Make every decision input reproducible
Wall-clock reads, random choices, external API results, unordered iteration, and application-version changes can all create different outcomes from apparently identical requests. A deterministic design must eliminate such differences, record them as agreed inputs, or provide a supported mechanism to resolve them consistently. Replaying an external payment call is especially dangerous because deterministic arguments about database state do not make the outside service idempotent. Define which effects belong to the replicated transaction and which need a separate delivery protocol.
Calvin’s scheduling depends on obtaining transaction read and write sets in advance. Data-dependent access can require a reconnaissance or planning mechanism and validation of what it discovered; it is not free support for arbitrary interactive transactions. Preserve the distinction between a business rule that deterministically declines a request and a system-level abort caused by execution uncertainty. A replay must reproduce the authorized logical behavior, while failures and membership changes follow the surrounding replication and recovery rules.
Unique order survives finite labels and restarts
An ordering position needs a stable identity across epochs, replay, and log compaction. A small wrapping slot number cannot identify an unlimited history by itself. Keep the epoch, sequence, or other protocol context that distinguishes reused positions. Observe ordering latency separately from execution and dependency waiting: a fast execution engine can still queue behind a saturated input-ordering service. Evaluate recovery time and access-planning overhead as well as steady-state throughput under the workloads the design actually supports.
The modular lab makes the label-reuse issue concrete. Reset, set modulus to 4 and additive step to 1, predict when the displayed residue returns to zero, then Step four times. For a fresh comparison, Reset and explicitly set modulus to 5 and additive step to 1, predict, then Step five times. Each Step advances one addition. This is a finite additive orbit, not Calvin’s sequencer or a transaction log; explain why returning to label zero does not mean the previous operation at zero is the same operation.
Work it through
Order two quota reservations
Quota starts at 10 units. Request A reserves 7 units if enough remain; request B reserves 5 under the same rule. Both inputs and the conditional rule are deterministic. Compare agreed order A then B with order B then A.
With A first, the state changes from 10 to 3 units. B then sees only 3, so its 5-unit reservation is declined and the final state remains 3.
With B first, quota becomes 5. A needs 7 and is declined, leaving 5. Both histories preserve nonnegative quota but serve different requests.
Replicas must use the same agreed order and rule to reproduce the same accepted request and final state. Identical initial data alone is insufficient when the operations do not commute.
Ordering is an application-visible choice. Deterministic execution must reproduce both successful mutations and business-rule declines.
The living notebook
Explore the model
Interactive lab · modular
A finite slot is not a unique history position
Reset, set modulus m = 4 and additive step a = 1, predict the return to zero, then Step four times. Compare a fresh Reset with both m = 5 and a = 1 before five Steps. This finite arithmetic orbit illustrates label reuse, not transaction ordering or log recovery.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA wrapping position needs protocol context to distinguish different operations occupying the same label.
Pause & reason
Check your understanding
Your turn
Try it yourself
Starting from quota 12, A conditionally reserves 8 and B conditionally reserves 6. Compute both serial orders. Name one implementation detail that can break replica agreement even if they agree on order.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Apply the capacity test against the current state after each earlier accepted request.
Compare with the solution
A then B accepts A, leaves 4, and declines B. B then A accepts B, leaves 6, and declines A. Replicas following one agreed order should match. A local time-based policy, unrecorded external lookup, random choice, or inconsistent application version can still make them diverge, so the replay contract must cover those inputs and code semantics.
Keep the idea
Take it with you
- Deterministic systems coordinate inputs and order before executing supported transactions.
- Parallel execution remains possible when required conflict ordering is preserved.
- Access planning, nondeterministic inputs, and stable history identity are explicit obligations.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.