Try
↑ ↓ move↵ openesc close

Two-phase commit lab

Run transactions across several participants, crash the coordinator after the votes, and watch the locks it leaves behind. Compare waiting, asking the other participants, and aborting on a timeout.

tick 1503 participants, Wait for the coordinatorchance all vote yes: 94%

Transactions

started
300
committed
227 (76%)
aborted by a no vote
12
coordinator crashes
14

Each transaction asks every participant to prepare, then commits only if all voted yes. A coordinator that crashes after the votes leaves its participants holding locks.

The cost of an in-doubt transaction

stuck now
2
turned away by locks
59 (19.7%)
longest lock hold
30 ticks
average lock hold
3.4 ticks
split outcomes
0

A transaction that touches the hot row while a stuck one holds its lock is turned away. A participant that aborts on its own, after the timeout, may disagree with a coordinator that had already chosen commit.

Stuck transactions over the last 120 ticks
Stuck transactions over the last 120 ticks. Text version available below the chart.035810161120recent ticksstuck

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Crash the coordinator

    Set coordinator crash to 0, read the turned-away share, then set it back to 5.

    Look for. With no crashes, nothing waits and no transaction is turned away by a lock. Each crash leaves participants holding locks for the whole downtime, and every transaction that wants the hot row meanwhile is turned away.

  2. A longer outage

    Raise coordinator downtime to 90 ticks.

    Look for. The locks are held three times as long, so far more transactions are turned away. Prepared participants cannot let go until they hear the decision.

  3. Ask the other participants

    Choose to ask the other participants and compare the stuck count with waiting.

    Look for. When the coordinator got the decision to one participant before it crashed, the others learn it from that one and finish early. When no one heard, they must still wait. Stalls fall, but the longest hold does not.

  4. Abort on a timeout

    Choose to abort after a timeout and read the split outcomes.

    Look for. Locks are freed after a few ticks, but the coordinator had already chosen commit. Participants that abort on their own break atomicity. The count of split outcomes is the price of the shortcut.

  5. More participants

    Raise participants from 3 to 8 with 5 percent no votes.

    Look for. The chance that all of them vote yes falls like a power, so more transactions abort. Every added participant is one more machine that can say no or be slow.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms