Maps to: CMU 15-440/640 Spring 2026 readings A. Borg, J. Baumbach and S. Glazer, A Message System Supporting Fault Tolerance (SOSP 1983), and A. Borg, W. Blau, W. Graetsch, F. Herrmann and W. Oberle, Fault Tolerance Under UNIX (ACM TOCS 1989); learning outcome “failures” (recovery). Uses Supplement S1 (logical time) informally. Project: P4’s nodes must recover from their logs after a crash. This lecture teaches recovery concepts with toy worlds; it contains no P4 code. Sources:
- the two readings;
- J. W. Young, A First Order Approximation to the Optimum Checkpoint Interval (CACM 1974);
- J. T. Daly, A Higher Order Estimate of the Optimum Checkpoint Interval for Restart Dumps (Future Generation Computer Systems 2006);
- B. Randell, System Structure for Software Fault Tolerance (IEEE TSE 1975), the domino effect;
- K. M. Chandy and L. Lamport, Distributed Snapshots: Determining Global States of Distributed Systems (ACM TOCS 1985);
- D. Briatico, A. Ciuffoletti and L. Simoncini, A Distributed Domino-Effect Free Recovery Algorithm (1984);
- R. Strom and S. Yemini, Optimistic Recovery in Distributed Systems (ACM TOCS 1985);
- E. N. Elnozahy, L. Alvisi, Y.-M. Wang and D. B. Johnson, A Survey of Rollback-Recovery Protocols in Message-Passing Systems (ACM Computing Surveys 2002).
The slides are not public; this is not a transcript. Every number not attributed to a paper comes from
code/lecture15/, run on the author’s machine (Apple M4 Pro, macOS, Python 3.13 and 3.9). All of it is exact or seeded simulation, except the checkpoint write times in §2.4, which are real measurements and vary from run to run. Code:code/lecture15/. Reading time: ~85 minutes, plus ~5 to run the demos.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Derive Young’s checkpoint interval √(2CM), know when Daly’s refinement matters, and explain why the optimum is flat.
- Draw a space-time diagram, decide whether a cut is consistent, and identify orphan and in-transit messages.
- Explain the domino effect of uncoordinated checkpoints, and compute a recovery line by rollback propagation.
- Describe coordinated checkpointing, the Chandy–Lamport snapshot (and why it needs FIFO channels), and communication-induced checkpointing.
- Compare pessimistic and optimistic message logging, explain the output commit problem, and say why every nondeterministic input must be logged.
- Explain how Auragen/TARGON made arbitrary Unix processes fault-tolerant with three-way message delivery, a sent count and periodic syncs.
0.2 Prerequisites and scope
- Prerequisites:
- Lecture 13: MTBF, the exponential cliff of long jobs, process pairs;
- Lecture 14: crash-recover failures, determinism of replicas;
- Lecture 4: duplicate detection and at-most-once execution;
- Lecture 1: dsim.
- Scope: rollback recovery of computations (processes exchanging messages). Recovery of data with atomicity guarantees — shadowing, intentions lists, write-ahead logging — is Lectures 16–17. Logical clocks and happened-before, which underlie consistent cuts, are Supplement S1.
0.3 Section → code map
| Section | Idea | Demo in code/lecture15/ |
|---|---|---|
| §2 | the checkpoint interval; a real checkpoint’s cost | 01_checkpoint_interval.py |
| §3 | cuts, orphans, messages in transit | 02_consistent_cuts.py |
| §4.1, §4.3 | the domino effect; coordinated and communication-induced checkpoints | 03_domino_effect.py |
| §4.2 | the Chandy–Lamport snapshot | 04_chandy_lamport.py |
| §5 | message logging, output commit, nondeterminism | 05_message_logging.py |
| §6 | Auragen-style process pairs | 06_process_pairs_auragen.py |
| all | the shared machinery | rollback.py, snapshot.py, msglog.py |
0.4 Notation
- W: work to do (failure-free running time).
- τ: compute time between checkpoints.
- C: cost of one checkpoint.
- R: restart time.
- M: mean time between failures of the whole system the job runs on.
- A process executes a sequence of events: local steps, sends, receives.
- A cut gives, for each process, how many of its events are included: c = (c₁, …, cₙ).
- A message is an orphan in a cut if its receipt is inside and its send outside; it is in transit if its send is inside and its receipt outside.
1. Why rollback recovery?
Lecture 13 ended with a sobering table: a 10-hour job that needs all of 1,000 machines, each with an MTTF of 1,000 hours, takes three years if every failure restarts it from scratch. The cure is to save progress. Periodically write the computation’s state to stable storage (a checkpoint); after a failure, restore the latest checkpoint and continue from there (rollback recovery).
This sounds simple, and for a single process it nearly is. The difficulties of this lecture come from three directions:
- Cost. Writing a checkpoint takes time; too frequent, and the job spends its life saving itself. Too rare, and each failure throws away a lot of work (§2).
- Distribution. A distributed computation is many processes exchanging messages. Restoring each process to some earlier state is not enough. The combination must be a state the system could actually have been in, otherwise one process remembers a message that, according to another, was never sent (§3–§4).
- The outside world. A process that has already printed a cheque, sent an e-mail or answered a client cannot take that back. Recovery must never contradict what the world has seen (§5).
Two ways of saving progress run through the lecture:
- Checkpointing saves states: a process’s memory, registers, open files.
- Message logging saves inputs: if a process is deterministic, its state is a function of the messages it received, so saving those messages, and replaying them after restoring an older checkpoint, rebuilds the state exactly.
The Auragen system of the readings combines both (§6).
What goes into a checkpoint depends on the level:
- application-level checkpoints save only the data structures the program chooses (small, but the programmer must write the code);
- system-level checkpoints save the whole address space (transparent, but larger). Tools of this kind include BLCR and CRIU on Linux, and whole-VM snapshots.
Incremental checkpoints save only pages changed since the last one; copy-on-write (fork the process and let the child write the snapshot) lets the computation continue while the checkpoint is written.
2. How often to checkpoint?
2.1 Young’s rule
Consider one process (or a tightly coupled job) that fails at rate 1/M. Per unit of work, checkpointing every τ costs two things:
- checkpoint overhead: C every τ, a fraction C/τ;
- lost work: a failure strikes, on average, halfway through an interval and throws away about τ/2. Failures come at rate 1/M, so this costs about τ/(2M) per unit of time.
Minimizing C/τ + τ/(2M) gives Young’s (1974) interval:
Its shape is worth remembering. The interval grows only with the square root of the MTBF: 100× more reliable machines justify checkpoints 10× less often. Lecture 1’s demo 06 found the same rule in Herbert Simon’s watchmakers: their best subassembly size was 13 parts against Young’s 14.1.
2.2 The exact model and Daly’s refinement
Young’s argument is first-order: it ignores failures during checkpoints and restarts, and the possibility of several failures in one interval. Daly (2006) wrote the exact expected time for exponential failures, with failures possible at any moment:
and derived a higher-order estimate of its minimum, τ ≈ √(2CM)[1 + ⅓√(C/2M) + ⅑(C/2M)] − C (for C < 2M).
Demo 01 Part A takes a week of work (W = 168 h) on a system with MTBF 24 h, 6-minute checkpoints and 10-minute restarts:
| interval | τ | expected completion | overhead |
|---|---|---|---|
| 15 min | 0.25 h | 238.6 h | 42.0% |
| 1 h | 1.00 h | 190.4 h | 13.3% |
| Young √(2CM) | 2.19 h | 185.6 h | 10.5% |
| Daly | 2.12 h | 185.6 h | 10.5% |
| exact optimum | 2.12 h | 185.6 h | 10.5% |
| 8 h | 8.00 h | 203.7 h | 21.3% |
| 24 h | 24.0 h | 292.6 h | 74.2% |
A Monte Carlo simulation of 3,000 runs at Young’s interval gave 185.5 ± 0.2 h. Without any checkpoint the job would take about 3 years (Lecture 13’s formula). Daly’s estimate matched the exact optimum to four digits. Young’s interval was 3% longer, and cost 0.004% more time.
2.3 A flat optimum, until failures get frequent
Part B shows that the exact choice hardly matters. Half or twice the optimal interval costs only +2.2% or +2.3%; a quarter or four times, about +10%. This is good news for practice, because C and especially M are never known precisely.
Part C shows where checkpointing stops working. As the MTBF approaches the checkpoint cost, efficiency (work done per unit of time) collapses:
| MTBF | best τ | efficiency | Young’s extra time |
|---|---|---|---|
| 41.7 days | 14.1 h | 99% | 0.00% |
| 24 h | 2.12 h | 91% | 0.00% |
| 1 h | 0.38 h | 52% | +0.47% |
| 15 min | 0.16 h | 18% | +3.6% |
This is the worry of exascale computing. Machines with millions of components have system MTBFs of hours, and writing petabytes of memory to storage takes many minutes. Remedies include faster checkpoints (to the memory of neighbouring nodes, to burst buffers), smaller ones (incremental, compressed), and avoiding global checkpoints altogether (message logging, §5).
Part D asks whether the exponential model matters, using failures with a decreasing hazard (Weibull k = 0.7) or an increasing one (k = 2), all with the same 24-hour mean. In this setting it did not. The best interval on the grid was the same (Young’s) for all three, and expected times differed by less than 0.4%. A week-long job sees many failures, and to first order only their rate matters.
2.4 What does a real checkpoint cost? (real)
Part E measures one checkpoint on the author’s laptop: serialize a state with pickle, write it, force it to storage, and switch it in with an atomic os.replace. That switch is the trick of Lecture 16.
| state | with fsync() | with F_FULLFSYNC | Young τ for MTBF 24 h |
|---|---|---|---|
| 1 MB | 0.4 ms | 3–5 ms | ~26 s |
| 16 MB | 2.8 ms | 7–8 ms | ~37 s |
| 64 MB | 7–8.5 ms | 18–19 ms | ~57 s |
The first measurement was a lesson in itself. 64 MB “checkpointed” in 8 ms is 7.5 GB/s, faster than the drive can write. On macOS, fsync() returns once the data has been handed to the drive, without flushing the drive’s own cache. A power failure could still lose it. Only fcntl(F_FULLFSYNC) waits until the data is durable. A checkpoint that is not on stable storage is not a checkpoint. Measure the durable cost, and plug that into Young’s formula.
3. Global states of a distributed computation
3.1 Cuts
A single process can checkpoint whenever it likes. A distributed computation cannot simply let each process checkpoint on its own and later restore “everyone’s checkpoint”. The combination may be a state that never happened.
Picture the computation as a space-time diagram: one horizontal line per process, events as points, messages as arrows from a send to a receive. A cut draws a line across the diagram and keeps, from each process, the events to the left of the line. A cut is consistent if it contains no orphan: no message whose receipt is inside and whose send is outside. An orphan cut shows an effect without its cause, like a bank statement that records a deposit the sender’s records say was never made. A message whose send is inside and whose receipt is outside is in transit. That is fine (it was in the network at that moment), but a snapshot or a recovery must account for it.
Demo 02 draws a small scripted history of three processes and three cuts (s3 is the send of message 3, r3 its receipt; the letters show where each cut crosses each process):
P0 s0 . AB s2 C r3
P1 r0 C s1 AB . s3
P2 . C r1 A r2 B .
| cut | events included | verdict | orphan | in transit |
|---|---|---|---|---|
| A | (2, 2, 2) | consistent | — | — |
| B | (2, 2, 3) | inconsistent | m2 | — |
| C | (3, 1, 1) | consistent | — | m2 |
Cut B includes P2’s receipt of m2 but not P0’s send: it never happened. Cut C includes the send but not the receipt: m2 is in the network.
3.2 How many states could have happened?
Of the 125 possible cuts of this little history, only 52 are consistent. They form a lattice: the componentwise minimum and maximum of any two consistent cuts are consistent too. Supplement S1 explains why. Consistent cuts are exactly the sets of events closed under happened-before: if an event is included, so is everything that happened before it.
Part C counts on random histories of three processes (about 8 events each). With no messages every cut is consistent. When 30% of actions are sends, 51% of cuts are; at 50% sends, 44.5%. Communication creates dependencies, and dependencies rule out combinations of local states.
Part D asks the question that matters for recovery. If four processes checkpoint independently, is the set of latest checkpoints consistent? In 41.8% of short histories (50 events) it is, mostly because few processes have checkpointed yet. In histories of 800 events it is consistent only 0.5% of the time. “Restore everyone’s latest checkpoint” is almost always wrong.
4. Coordinating checkpoints
4.1 Uncoordinated checkpoints and the domino effect
Suppose processes checkpoint independently and process P fails. P restarts from its latest checkpoint. Any message P sent after that checkpoint is now unsent, so a process that received it holds an orphan and must roll back to a checkpoint before the receipt. That rollback unsends its messages, which may orphan a third process, and so on. This is the rollback propagation that rollback.recovery_line performs. The cascade can run all the way back to the beginning: Randell’s domino effect (1975).
Demo 03 Part A shows it on a short history. Each of three processes took two or three checkpoints. P0 fails at the end:
- P0 restarts from its latest checkpoint (position 7).
- m10 was received by P1 but its send by P0 is undone → P1 rolls back to its initial state.
- m0 was received by P0 but its send by P1 is undone → P0 rolls back to its initial state.
- m6 orphans P2 → P2 rolls back to position 4.
- m2 orphans P2 again → P2 rolls back to its initial state.
All 36 events of the history are lost, despite eight checkpoints. Checkpoints that do not line up with each other are useless.
Part B measures the damage over 300 runs of 4 processes and 400 steps, with one failure at the end:
| checkpoints | per process | work lost | back to the start |
|---|---|---|---|
| uncoordinated, 1% per event | 1.0 | 93.9% | 82% |
| uncoordinated, 3% | 3.0 | 79.6% | 49% |
| uncoordinated, 10% | 10.0 | 20.8% | 0% |
| coordinated, every 100 steps | 3.0 | 24.9% | 0% |
| coordinated, every 50 steps | 7.0 | 11.0% | 0% |
| CIC, basic 1% (1.9 of 3.0 forced) | 3.0 | 24.4% | 1% |
| CIC, basic 3% | 6.6 | 8.7% | 0% |
With about three checkpoints per process, uncoordinated checkpointing lost 80% of all work and went back to the start in half the failures. Coordinated or communication-induced checkpoints lost about a quarter. Even ten uncoordinated checkpoints per process did worse than seven coordinated ones. Part C confirms the cause: the share of work lost grew from 38% to 80% as the share of actions that send rose from 5% to 30%.
4.2 Coordinated checkpoints, and the Chandy–Lamport snapshot
The obvious cure is to make all processes checkpoint “at the same time”, so that their checkpoints form a consistent cut. Two ways to do it badly, and one to do it well (demo 04, a bank of four branches that keep transferring money; the total is always 4,000):
| method | exact total (200 runs) | mean error | cost |
|---|---|---|---|
| each branch records its balance when its own clock reads 100 ms (perfect clocks) | 0/200 | 154 | none |
| the same, clocks ±5 ms | 0/200 | 153 (worst 359) | none |
| stop all transfers, wait 10 ms, read balances | 200/200 | 0 | the bank stops for 10 ms |
| Chandy–Lamport | 200/200 | 0 | 12 markers, 15.7 ms, no pause |
| Chandy–Lamport on non-FIFO channels | 7/200 | 42 | — |
- Recording at the same instant fails even with perfect clocks: it misses the money in the wires (on average 154 units). Synchronized clocks are not enough. The messages in transit are part of the global state.
- Stopping the world works, but it halts the computation, and it relies on a known bound on message delay (synchrony again).
- The Chandy–Lamport algorithm (1985) records a consistent global state while the computation keeps running. About ten transfers happened during each snapshot. Its rules:
- the initiator records its own state and sends a marker on every outgoing channel;
- when a process receives its first marker (say on channel c), it records its state, records c as empty, sends markers on all its outgoing channels, and starts recording every other incoming channel;
- when it receives a marker on a channel it is recording, the state of that channel is the messages that arrived on it since the process recorded its own state.
Why does it work? The marker on channel c separates the messages the sender sent before recording its state from those it sent after. Messages before the marker are in the sender’s past and may still be in transit; the receiver records them as channel state if they arrive after its own recording. Messages after the marker belong to the sender’s future and are excluded. This requires FIFO channels: if a later message could overtake the marker, it would be counted although its send is outside the cut. On non-FIFO links only 7 of 200 snapshots added up.
One subtlety. Demo 04 Part B prints the recorded balances (829 / 1,153 / 938 / 970) next to the actual balances when the snapshot began (829 / 1,153 / 964 / 966). They differ. The recorded global state may never have existed at any single instant. It is a state the system could have passed through, a consistent cut, and that is all that recovery, deadlock detection or “does the money still add up?” require.
Chandy–Lamport is used well beyond banks:
- stream processors take their periodic checkpoints this way (Apache Flink’s asynchronous barrier snapshots inject markers, “barriers”, into the data streams);
- termination detection, deadlock detection and distributed debugging all use it to evaluate a property of a global state.
4.3 Communication-induced checkpointing
A third approach lets processes checkpoint on their own but piggybacks information on every message, and takes a forced checkpoint when needed to keep checkpoints consistent. In the index-based scheme of Briatico, Ciuffoletti and Simoncini (1984), each process numbers its checkpoints and attaches its current number to every message. A process that receives a message carrying a larger number first takes a forced checkpoint with that number, then delivers the message. Checkpoints with the same number then always form a consistent cut (our self-test checks this on random histories).
In demo 03, CIC with basic checkpoints at 1% per event took 1.9 forced checkpoints per process (3.0 in all) and lost 24.4% of the work, about the same as coordinated checkpoints, without any coordination messages.
4.4 Comparison
| uncoordinated | coordinated (blocking or snapshot) | communication-induced | |
|---|---|---|---|
| when processes checkpoint | when convenient | together (a round of messages, or markers) | on their own, plus forced ones |
| consistency | not guaranteed: domino effect | guaranteed | guaranteed by forced checkpoints |
| extra messages | none | markers, or a coordination round | none (piggybacked numbers) |
| rollback after one failure | unbounded | to the last global checkpoint | bounded |
| storage | must keep many checkpoints (garbage collection is hard) | one per process | several |
| in-transit messages | must be logged or lost | recorded in the snapshot | must be logged or lost |
5. Message logging
5.1 Replay instead of rollback
Checkpointing alone makes every process roll back together. Message logging lets the failed process recover alone. It rests on the piecewise deterministic (PWD) assumption: a process’s execution is a sequence of deterministic intervals, each started by a nondeterministic event, typically the receipt of a message. If we record the information needed to replay each such event — its determinant, such as which message was delivered in which order, or the value a clock read returned — then from a checkpoint the process can be rolled forward to exactly the state it had. Nobody else has to roll back, and the messages it sends during replay are identical to the ones it sent before. The question is when the log must reach stable storage.
Demo 05 runs a server whose state depends on the order of the requests it processes. Clients retransmit unanswered requests. The server checkpoints every 25 requests, a stable write costs 2 ms, and the server crashes once per run (40 runs per row):
| recovery scheme | median reply | stable writes | acknowledged but forgotten | contradicted |
|---|---|---|---|---|
| checkpoints only, no log | 1.22 ms | 3 | 12.4 | 0 |
| pessimistic log (write, then process) | 3.95 ms | 103 | 0 | 0 |
| optimistic log (background, every 10 ms) | 1.23 ms | 44 | 0.95 | 0 |
| optimistic + output commit | 8.03 ms | 43 | 0 | 0 |
| pessimistic, processing reads a clock (not logged) | 3.95 ms | 103 | 0 | 12.7 |
| pessimistic, clock readings logged too | 3.95 ms | 103 | 0 | 0 |
“Acknowledged but forgotten” and “contradicted” are both orphan outputs: a client was told something about a state that, after recovery, no longer exists. In the first case the recovered server has no trace of a request it acknowledged. In the second it computed a different result for it.
5.2 Pessimistic logging
Write each message to stable storage before processing it. Recovery is then always exact: everything the process ever acted on is in the log. The price is a synchronous stable write on the critical path of every message. In the demo that is 103 writes per run and a median reply of 3.95 ms instead of 1.22.
Variants reduce the price:
- log at the sender, in its volatile memory (sender-based logging);
- keep the log in the memory of a different machine. That is Auragen’s approach (§6): it survives any single failure without a disk write.
5.3 Optimistic logging
Process at once, write the log in the background (Strom and Yemini 1985). Normal operation is as fast as with no log (1.23 ms), and the writes are batched (44 instead of 103). But a crash loses the tail of the log that had not been written. A process whose state depended on those lost messages becomes an orphan and must roll back too. Here the orphans are the clients: in each crash, about one acknowledged request (0.95) was forgotten. Between processes, optimistic logging needs to track dependencies so that orphans can be found and rolled back.
5.4 The output commit problem
The outside world — a user, a printer, an ATM — cannot roll back. So before a process sends a message to the outside world, everything that message depends on must be stable. This is the output commit rule. With output commit, the optimistic log produced no orphans, but replies waited for the next log write: a median of 8.03 ms instead of 1.23.
Part B varies the flush interval of the optimistic log:
| flush every | stable writes per run | forgotten (optimistic) | median reply (output commit) |
|---|---|---|---|
| 2 ms | 82 | 0.50 | 4.2 ms |
| 10 ms | 44 | 0.95 | 8.0 ms |
| 50 ms | 13 | 3.95 | 25.7 ms |
Frequent flushes cost writes; rare flushes cost risk (or, with output commit, reply latency). The same trade-off reappears in Lecture 17. A database must make its log durable before acknowledging a commit, and group commit amortizes one log write over many transactions. That is exactly the batching in this table.
Causal logging (Alvisi and Marzullo) is a third option. Instead of writing determinants to stable storage synchronously, it piggybacks them on outgoing messages, so that every process that could become an orphan already holds the information needed to replay the events it depends on.
5.5 Nondeterminism must be logged
Replay rebuilds the same state only if the process is truly piecewise deterministic. In the demo’s fifth row, the server mixed a clock reading into its state while processing each request. Requests were logged, but the clock values were not. After recovery, replay read the clock again, got different values, and computed different digests: 12.7 replies per run were contradicted by the recovered state. Logging the readings as determinants made recovery exact again. Part C shows one recovery up close: replaying 7 logged requests rebuilt the digest exactly, except in the run with unlogged clock reads.
Sources of nondeterminism in real programs are everywhere:
- clocks and timers;
- random numbers;
- the order in which threads acquire locks;
- signals and interrupts;
select()choosing among ready inputs;- even uninitialized memory.
Each must be logged or eliminated. The same technique powers deterministic replay debugging (record a run once, replay it identically as often as you like; for example Mozilla’s rr) and VM fault tolerance (VMware FT records the nondeterministic events of a primary VM and replays them on a backup).
6. Case study: Auragen and TARGON/32 (the readings)
6.1 The goal
Borg, Baumbach and Glazer (1983) set out to make every process on a Unix system survive any single hardware failure, with three requirements (paper’s goals):
- transparency: no program changes, no special programming;
- efficiency in normal operation: the backup hardware must do useful work, not sit idle;
- automatic detection and recovery, with a user at a terminal noticing at most a short delay.
Compare Gray’s process pairs (Lecture 13 §7.3). Tandem’s checkpointing pairs needed the programmer to send state to the backup; Auragen does it in the operating system.
6.2 The mechanism
Every primary process has an inactive backup on another machine. The backup is a reserved process slot plus saved state and messages; it does not execute. The design rests on one assumption, determinism: two processes that start in the same state and receive the same messages in the same order behave identically.
-
Three-way delivery. Every message from one process to another is delivered atomically to three places:
- the destination primary, which queues it for reading;
- the destination’s backup, which saves it for a possible replay;
- the sender’s backup, which just increments a count of messages its primary has sent since the last sync, and discards the message.
The hardware bus and low-level protocols guarantee that all three receive the message or none do, and that two messages never interleave, so a primary and its backup see messages in the same order.
-
Periodic sync. When the primary has read more than a set number of messages, or run longer than a set time, it syncs: its changed pages are saved for the backup, and a small sync message tells the backup how many messages the primary has read. The backup discards those messages and resets its sent count.
-
Recovery. When a primary’s machine fails, its backup starts from the state of the last sync. It reads the saved messages in the same order, and so retraces the primary’s execution exactly. Each time it is about to send a message, it checks the count. If the count is positive, the primary already sent this message: decrement and do not send. Otherwise send. The outside world therefore sees each message exactly once.
-
Making Unix deterministic. The hard part was the sources of nondeterminism (paper’s details):
- the
timesystem call became a request to a server process, so its answer arrives as a message that the backup also has; - process ids became global;
- reads must block rather than return “no message yet”, since the backup might find its queue in a different state;
- an asynchronous signal makes the process sync just before handling it, so that the backup finds the signal at the same point.
Operating-system services that must survive a crash, such as file and page management, were moved out of the kernel into backed-up server processes.
- the
-
Backup modes (1983 paper):
- quarterbacks get no new backup after a crash;
- halfbacks get one when the failed machine returns;
- fullbacks get one immediately, which needs at least three machines.
6.3 Demo 06
Demo 06 builds this scheme on dsim: a message bus that delivers atomically and in order, a primary, an inactive backup that saves messages, and a sent count. The primary crashes at a random moment; the backup takes over 50 ms later.
| recovery | replies missing | duplicate replies | contradicted |
|---|---|---|---|
| backup suppresses already-sent outputs using the count | 0 | 0 | 0 |
| no sent count: the backup re-sends what it replays | 0 | 1,143 (in 30 crashes) | 0 |
The count is what makes recovery exactly-once. Without it, every output since the last sync is sent twice, which is harmless only if every client is idempotent.
The sync interval N trades normal-operation cost against memory and recovery time (sync cost 5 ms of the primary’s time; one request per ms):
| sync every N | primary’s time syncing | backup’s saved requests (max) | recovery (50 ms detection + replay) |
|---|---|---|---|
| 4 | 71% (overloaded) | 803 | 313 ms |
| 16 | 31% | 81 | 83 ms |
| 64 | 7.4% | 119 | 96 ms |
| 256 | 1.7% | 295 | 148 ms |
| 1,024 | 0.2% | 1,044 | 347 ms |
Two things differ from the checkpoint-interval story of §2:
- A long interval loses no work: every message is saved. It costs backup memory and recovery time (replay).
- A short interval can overload the primary. At N = 4 the primary needed 1.75 ms of work per 1 ms of arrivals. Its backlog, which the backup also saved and had to replay, made recovery slower than at N = 16.
6.4 What Borg et al. measured
The 1989 paper reports on TARGON/32, the completed system (paper’s numbers):
- the distributed, message-based organization cost about 15% against a standard Unix machine, and fault tolerance about 10% more;
- adding a second machine increased performance by about 70%, so a two-machine fault-tolerant system ran at about 1.6 times a standard Unix machine;
- the optimum sync frequency was every 64 messages;
- a user whose primary process died saw a delay of 5–15 seconds.
6.5 Descendants
The ideas of these papers live on:
- VM-level fault tolerance. VMware FT records the nondeterministic events of a primary VM and replays them on a backup. Remus (Cully et al., 2008) checkpoints a whole VM to a backup tens of times per second and buffers network output until the checkpoint is acknowledged: output commit again.
- Stream processors (Flink, Spark Streaming) combine coordinated snapshots (§4.2) with replayable input logs (Kafka) to give exactly-once results.
- Databases use write-ahead logs whose records are replayed after a crash, with the output-commit rule applied to commit acknowledgements (Lecture 17).
- State machine replication (Lectures 20–21) replays an agreed log of commands on every replica: message logging with consensus instead of a hardware bus.
7. Design rules
- Checkpoint about every √(2CM), with C the durable checkpoint cost. Do not agonize over the exact value: the optimum is flat.
- If the MTBF approaches C, checkpoints cannot save you. Make them cheaper, incremental or local, or avoid global rollback.
- A distributed checkpoint must be a consistent cut. Coordinate (Chandy–Lamport markers, a blocking round) or piggyback (CIC); never just restore everyone’s latest checkpoint.
- Account for messages in transit at the recovery line: record them (snapshot) or log them.
- Chandy–Lamport needs FIFO channels; recording “at the same time” does not work even with perfect clocks.
- Log to recover alone. Pessimistic: exact, but a stable write per message. Optimistic: fast, but orphans.
- Output commit: nothing leaves for the outside world until what it depends on is stable.
- Log every source of nondeterminism, or remove it.
- Exactly-once outputs after takeover need a way to know what was already sent: Auragen’s count, sequence numbers, or idempotent receivers.
Summary
- Checkpoint interval: Young’s √(2CM) balances checkpoint overhead C/τ against lost work τ/(2M).
- For 168 h of work with MTBF 24 h and 6-minute checkpoints: Young 2.19 h, Daly = exact optimum 2.12 h, 185.6 h in all (3 years without checkpoints).
- The optimum is flat (±2% for a factor of 2).
- Efficiency collapses as MTBF approaches C (18% at MTBF 15 min).
- Real: a durable 64 MB checkpoint cost ~19 ms, not the 8 ms
fsync()suggests.
- Consistent cuts contain no orphan message.
- 52 of 125 cuts of a small history were consistent, forming a lattice.
- Communication rules out combinations of states.
- Everyone’s latest independent checkpoint was consistent in 0.5% of long histories.
- The domino effect:
- uncoordinated checkpoints lost 80% of the work with 3 checkpoints per process (49% of failures back to the start), and rollback propagation erased a whole 36-event history in Part A;
- coordinated checkpoints (25%) and communication-induced ones (24%) bound it.
- Chandy–Lamport recorded the bank’s total exactly in 200/200 runs while it kept running.
- Same-instant recording failed even with perfect clocks (money in transit).
- Non-FIFO channels broke it (7/200).
- The recorded state was consistent but never existed at one instant.
- Message logging lets one process recover alone:
- pessimistic: exact, 103 stable writes, 3.95 ms replies;
- optimistic: fast but ~1 orphan output per crash;
- output commit: no orphans, 8 ms replies;
- unlogged nondeterminism: 12.7 contradicted replies per run.
- Auragen/TARGON (the readings): three-way atomic delivery, a sent count and syncs gave transparent exactly-once recovery.
- In demo 06: 0 duplicates, 1,143 without the count.
- The paper’s sync interval: 64 messages, ~10% overhead, 5–15 s recovery.
Common pitfalls
- Computing Young’s interval with a non-durable checkpoint cost (
fsync()on macOS, writes still in a cache). - Restoring every process’s latest checkpoint without checking consistency.
- Forgetting messages in transit at the recovery line.
- Snapshotting by timestamp, even with perfect clocks.
- Running Chandy–Lamport over channels that can reorder.
- Optimistic logging plus external outputs without output commit.
- Logging messages but not the clock reads, random numbers or thread interleavings the process depends on.
- Re-sending outputs during replay without suppression or idempotent receivers.
- Syncing so often that the primary cannot keep up.
Exercises
-
Young’s interval. A simulation runs on a cluster whose MTBF is 6 hours. A checkpoint takes 30 seconds; a restart 2 minutes. (a) Compute Young’s interval. (b) Estimate the overhead (checkpointing + lost work) at that interval. (c) The team buys storage that makes checkpoints 4× faster. How do the interval and the overhead change?
Answer
(a) τ = √(2 × 30 s × 21,600 s) = √1,296,000 ≈ 1,138 s ≈ 19 minutes. (b) Checkpointing costs C/τ = 30/1,138 ≈ 2.6%, lost work ≈ τ/(2M) = 1,138/43,200 ≈ 2.6% (equal at the optimum), plus restarts R/M = 120/21,600 ≈ 0.6%: about 5.8%. (c) C = 7.5 s: τ halves (√4 = 2) to ≈ 9.5 minutes, and both overhead terms halve to ≈ 1.3% each: about 3.2% in all with the restarts. A 4× faster checkpoint buys a 2× smaller overhead. -
When Young fails. Explain in words why Young’s first-order formula overestimates the best interval when C is not small compared with M, and why Daly’s estimate subtracts C.
Answer
Young assumes at most one failure per interval and that failures never strike during checkpoints or restarts. When C is a sizable fraction of M, failures during the checkpoint itself and multiple failures per interval become likely. The work at risk is then τ + C, not τ, and the expected loss grows faster than linearly with the interval (the exponential in the exact formula). Both effects favour shorter intervals. Daly's expansion adds correction terms in √(C/M) and subtracts C because the vulnerable period is compute plus checkpoint: the optimum is about √(2CM) for the *total* segment, so the compute part is √(2CM) − C, refined further by the higher-order terms. Demo 01 Part C shows the gap: Young is 3.6% worse than the optimum when M = 15 min and C = 6 min. -
Is this cut consistent? Three processes. P0 sends m1 to P1 as its 2nd event; P1 receives m1 as its 3rd event and then sends m2 to P2 as its 4th; P2 receives m2 as its 2nd event. For each cut, say whether it is consistent and list in-transit messages: (a) (2, 4, 1); (b) (1, 4, 2); (c) (2, 2, 0).
Answer
The send of m1 is P0's event index 1 (0-based), included iff c₀ ≥ 2; its receipt is P1's index 2, included iff c₁ ≥ 3. The send of m2 is P1's index 3 (c₁ ≥ 4); its receipt is P2's index 1 (c₂ ≥ 2). (a) m1 sent and received: fine; m2 sent (c₁ = 4) but not received (c₂ = 1): in transit. Consistent, m2 in transit. (b) m1 received (c₁ = 4 ≥ 3) but not sent (c₀ = 1): orphan. Inconsistent. (c) m1 sent but not received (c₁ = 2): in transit; m2 not sent, not received. Consistent, m1 in transit. -
Build a domino. Construct a two-process history with checkpoints in which a failure of P0 at the end rolls both processes back to their initial states, even though each took at least one checkpoint.
Answer
A minimal zigzag (found by `rollback.py`'s search; local events omitted). P1 sends m0 to P0. P0 receives m0, then checkpoints (C0), then sends m2 to P1. P1 receives m2, then checkpoints (C1). Both continue, and P0 fails. (1) P0 restarts from C0, so its send of m2 is undone. (2) P1 received m2 before C1, so it must roll back to a checkpoint *before* that receipt: only its initial state qualifies. (3) That undoes P1's send of m0, which P0 received before C0, so P0 must roll back before C0: to its initial state. Both are back at the start, though each took a checkpoint. The pattern: each checkpoint sits just after a receipt of a message whose send the other process will lose. A checkpoint taken right *after* every send breaks the chain, since a restored process then never un-sends anything (at the price of a checkpoint per message); so do coordinated checkpoints. -
Chandy–Lamport by hand. Two processes, A and B, with FIFO channels both ways. A has 50 units, B has 50. A sends 10 to B (message x), then initiates the snapshot. Before the marker from A arrives, B sends 5 to A (message y). B then receives x, then the marker. A receives y, then B’s marker. What does each process record, and what is the total?
Answer
A records its state right after sending x: 40. It starts recording channel B→A. B receives x (its balance becomes 60 − 5 = 55, having already sent y) and then the marker; on the marker it records its state, 55, records channel A→B as empty, sends a marker to A, and is done (it has only one incoming channel). A then receives y (5) on B→A, which it is recording, so channel B→A holds 5; then B's marker ends the recording. Total: 40 + 55 + 0 + 5 = 100. Note that x, in transit when A recorded, is correctly counted in B's state, because B received it before the marker. FIFO guarantees that x arrives before the marker. -
Why FIFO? Show, with two processes and one transfer, how a non-FIFO channel makes Chandy–Lamport double-count money.
Answer
A (100) initiates: it records 100 and sends a marker to B, then sends a transfer of 10 to B (A's balance is now 90, but its recorded state is 100). On a non-FIFO channel the transfer overtakes the marker. B receives the 10 first (balance 110), then the marker, and records 110. Recorded total: A 100 + B 110 + channel A→B (empty: B recorded it empty on the first marker) = 210, though only 200 exist. The 10 is counted in A's recorded state (sent after A recorded) and in B's (received before B recorded). With FIFO, the transfer would arrive after the marker and appear only in A's recorded state. -
Choosing a logging scheme. A payment service processes 2,000 requests per second; a synchronous log write costs 1 ms on its SSD (writes can be batched); clients must never see a confirmation that is later lost. Compare pessimistic logging (one write per request), optimistic logging (a batch every 5 ms) without output commit, and optimistic logging with output commit (group commit), in throughput limits, added latency and correctness.
Answer
Pessimistic, one write per request: 2,000 synchronous writes per second at 1 ms each would need 2 s of write time per second. Impossible on one device without batching, and it adds ≥ 1 ms to every request even at low load. Optimistic, a batch every 5 ms: 200 writes per second (10 requests each), negligible added latency, but a crash loses up to 5 ms of confirmed payments (~10). That violates the requirement, since confirmations can become orphans. Optimistic with output commit (group commit): the same 200 batched writes per second, and confirmations wait for the batch containing their request to be durable, about 2.5 ms on average plus the 1 ms write. It meets the requirement at ~3.5 ms of added latency: the choice. This is what databases do (Lecture 17). -
Auragen in detail. A primary has sent 7 messages since its last sync, and read 12; the backup has saved 15 messages since the sync. The primary’s machine dies. (a) Which messages does the backup replay, and how many outputs does it suppress? (b) The program calls
gettimeofday()directly through a hardware register instead of thetimesystem call. What goes wrong?Answer
(a) The backup restores the sync state and reads all 15 saved messages in order: the 12 the primary had read (re-executing exactly what the primary did) and then the 3 it had not read yet, which it processes as the new primary. While re-executing, it would send the same 7 messages the primary sent; the count is 7, so it suppresses those 7 and sends normally from then on. (b) A clock read that bypasses the message system is a nondeterministic input that the backup cannot see. During replay it reads a different time, so its execution can diverge from the primary's: different outputs, a different state. Its count-based suppression then hides messages that differ from the ones actually sent. Auragen avoided this by making `time` a request to a server process, whose reply arrives as a message saved for the backup: the clock reading becomes a logged determinant.
Related project and problem set (concepts only)
-
Project 4 (two-phase commit) requires each node to write what it must remember to stable storage before acting on it, and to recover from its log after a crash. §5’s rules carry over:
- log before you act (pessimistic);
- do not tell the outside world before your log is durable (output commit);
- make replay deterministic.
Lectures 16–18 build the transaction concepts. No project code here.
-
No problem set asks about this lecture’s specific algorithms; PS3’s failure arithmetic draws on §2’s reasoning.
Further reading
- A. Borg, J. Baumbach and S. Glazer, “A Message System Supporting Fault Tolerance”, SOSP 1983.
- A. Borg, W. Blau, W. Graetsch, F. Herrmann and W. Oberle, “Fault Tolerance Under UNIX”, ACM TOCS 7(1), 1989.
- E. N. Elnozahy, L. Alvisi, Y.-M. Wang and D. B. Johnson, “A Survey of Rollback-Recovery Protocols in Message-Passing Systems”, ACM Computing Surveys 34(3), 2002 — the standard reference for everything in §3–§5.
- K. M. Chandy and L. Lamport, “Distributed Snapshots: Determining Global States of Distributed Systems”, ACM TOCS 3(1), 1985.
- J. W. Young, “A First Order Approximation to the Optimum Checkpoint Interval”, CACM 17(9), 1974; J. T. Daly, “A Higher Order Estimate of the Optimum Checkpoint Interval for Restart Dumps”, FGCS 22(3), 2006.
- R. Strom and S. Yemini, “Optimistic Recovery in Distributed Systems”, ACM TOCS 3(3), 1985.
- B. Cully et al., “Remus: High Availability via Asynchronous Virtual Machine Replication”, NSDI 2008.
- P. Carbone et al., “Lightweight Asynchronous Snapshots for Distributed Dataflows”, arXiv 1506.08603, 2015 (Flink’s checkpoints).
Preview of Lecture 16 — Atomic transactions I: ACID, shadowing and intentions lists
Checkpoints and logs protect a computation. Lecture 16 turns to data: how to change several things on disk so that a crash at any instant leaves either all of the changes or none. It covers:
- the transaction abstraction and its ACID properties;
- stable storage built from unreliable disks;
- two classic implementations: shadowing (copy, then swing one pointer) and intentions lists (write down what you will do, then a commit record, then do it).
A toy disk crashes after every possible write, to check that both implementations really are all-or-nothing.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| checkpoint / restart | 检查点 / 重启 |
| rollback recovery | 回滚恢复 |
| checkpoint interval | 检查点间隔 |
| Young’s formula / Daly’s estimate | Young 公式 / Daly 估计 |
| stable storage | 稳定存储 |
| application-level / system-level checkpoint | 应用级 / 系统级检查点 |
| incremental checkpoint | 增量检查点 |
| copy-on-write | 写时复制 |
| space-time diagram | 时空图 |
| event / local state / global state | 事件 / 局部状态 / 全局状态 |
| cut / consistent cut | 割 / 一致割 |
| orphan message | 孤儿消息 |
| in-transit message | 在途消息 |
| lattice | 格 |
| happened-before | 先行发生(因果先于) |
| recovery line | 恢复线 |
| rollback propagation | 回滚传播 |
| domino effect | 多米诺效应 |
| uncoordinated / coordinated checkpointing | 非协调 / 协调检查点 |
| communication-induced checkpointing (CIC) | 通信诱导检查点 |
| forced checkpoint | 强制检查点 |
| snapshot (Chandy–Lamport) | 快照(Chandy–Lamport 算法) |
| marker | 标记消息 |
| channel state | 通道状态 |
| FIFO channel | 先进先出通道 |
| message logging | 消息日志 |
| piecewise deterministic (PWD) | 分段确定性 |
| determinant | 决定因子(非确定事件记录) |
| pessimistic / optimistic / causal logging | 悲观 / 乐观 / 因果日志 |
| orphan process / orphan output | 孤儿进程 / 孤儿输出 |
| output commit | 输出提交 |
| group commit | 组提交 |
| deterministic replay | 确定性重放 |
| nondeterministic event | 非确定性事件 |
| primary / inactive backup | 主进程 / 非活动备份 |
| three-way (atomic multi-destination) delivery | 三方(原子多目标)投递 |
| sync (synchronization point) | 同步点 |
| roll forward | 前滚 |
| duplicate suppression | 重复抑制 |
| exactly-once | 恰好一次 |
| quarterback / halfback / fullback (backup modes) | 四分卫 / 中卫 / 后卫(备份模式) |