Chapter

13

Distributed systems, honestly

Part V · Real systems

  • 5 lessons
  • 3 h 40 min of core lessons
  • Skills: hostile-env, intent, evidence

Lessons

About

Two-phase commit is "solved". So where does it block? This chapter specifies real protocols with their failures switched on: coordinators that crash, votes that never arrive, clocks that run slow, leaders that have been replaced and do not know it. Each lesson checks the safety a protocol can keep, and names the assumption its liveness rests on.

The goals: specify protocols with failures included; separate safety from liveness, and name the assumption each one rests on; model time without clocks; and check a cut-down version of Raft's log replication.

Before you start

  • Chapter 08 (messages in a set), chapters 09 and 10 (liveness and fairness), and chapter 12 (what a bounded check covers).
  • A working ./tla doctor (see START.md).
  • Time: the chapter page shows the estimate, generated from the lessons.

What else is here

  • specs/: TwoPhaseCommit, SingleDecree, LeaderElection, LeaseLock and RaftLite, plus the broken variants the lessons run.
  • review/ (13-review): a teammate's stock reservation that fixes a stuck-order incident.
  • ai/1-two-leaders/ (13-ai1): an agent's refactor of LeaderElection, and a message that says nothing changed.
  • ai/2-correct-lease/ (13-ai2): an AI-written lease with renewal. Decide, with evidence, whether its claim holds.
  • gate/ (13-gate): a leader lease with crashes; gate/twin/ (13-gate-twin): shard ownership. The skeletons supply the interface only; you write the cfg too.

Run it

From the repository root:

shell
./tla check 13-01
./tla check 13-review
./tla check --gate 13

Skills

hostile-env (modelling a hostile environment), intent (stating intent as properties), evidence (knowing what a check covers).

Elsewhere

  • Web version: https://indicogni.com/learn/tla-plus/13-distributed-systems/
  • Recaps: CONCEPTS.md. Hints and explanation checks: HINTS.md. Predictions without answers: PREDICT.md.
  • Solutions: solutions/chapters/13-distributed-systems/, including the gate references and their mutants.
  • Further reading: Jim Gray's Notes on Data Base Operating Systems (1978) for two-phase commit, Leslie Lamport's Paxos Made Simple (2001) for agreement, and Diego Ongaro and John Ousterhout's Raft paper (2014). The specs here, their names and their constants are the course's own.

Beyond the lessons

  • 13-review Review a teammate’s spec · chapters/13-distributed-systems/review/ · ./tla check 13-review
  • 13-ai1 AI item · chapters/13-distributed-systems/ai/1-two-leaders/ · ./tla check 13-ai1
  • 13-ai2 AI item · chapters/13-distributed-systems/ai/2-correct-lease/ · ./tla check 13-ai2
  • 13-gate Gate · ./tla check --gate 13

    Hints

    Hint 1

    Start with the owner's two sentences. In this spec, what does "a leader" mean in terms of the variables? The requirement says it exactly: a node acts as leader while something about it holds.

    Hint 2

    Liveness needs fairness, and the README lists what operations can deliver: time passes, a crashed node restarts, and a free lease is taken. Write one conjunct for each, and ask for each whether its step stays enabled until it happens. Nothing else gets fairness.

    Hint 3 (nearly the answer; opening it marks a pass as "passed with help")

    Safety and Liveness are both about belief: one about two nodes, the other about some node, again and again. The fairness conjuncts are about Tick, Restart and Acquire, and none of them is about Renew, Release or Crash.

  • 13-gate-twin Gate twin, another domain · ./tla check --gate 13 --twin

    Hints

    Hint 1

    Start with the owner's two sentences. In this spec, what does "serving the shard" mean in terms of the variables? The requirement says it exactly.

    Hint 2

    Liveness needs fairness, and the README lists what operations can deliver: time passes, a failed server recovers, and a free shard is claimed. Write one conjunct for each, and ask whether its step stays enabled until it happens.

    Hint 3 (nearly the answer; opening it marks a pass as "passed with help")

    Safety and Liveness are both about serving: one about two servers, the other about some server, again and again. The fairness conjuncts are about Tick, Recover and Claim, and none of them is about Extend, HandBack or Fail.