Section 8.5

Failure atomicity

Definition

Failure atomicity is the guarantee that if a failure such as a crash or a loss of power stops an operation part way, then after the recovery procedure runs, the system is in exactly the state from before the operation or exactly the state the operation was meant to produce, never a mixture. The recovery procedure is the code that checks stored data when the system starts. Failure atomicity constrains what recovery accepts, not which bytes remain in storage: incomplete data may remain, as long as recovery never uses it.

Where it fits

Main entry: Atomicity (§8.3).

Failure atomicity is atomicity in which the observer is the recovery procedure after a failure. The Atomicity entry treats every kind of observer and works through a two-slot example. Failure atomicity is stricter than crash consistency §8.4, which requires only that the recovered state satisfy the system’s invariants, for example by keeping three of five appended records. It does not include durability §8.2: the old state is an allowed outcome, unless the operation had already been reported as complete and the system also promises durability.

The usual mechanism writes the new data to a place that recovery ignores, checks it, and then makes one small write, to a commit record §8.21, that switches recovery from the old data to the new. Shadow paging §8.9, copy-on-write §8.11 and A/B update §8.10 work this way. Write-ahead logging §8.12 first records the intended change in a log, so that recovery can complete the change or cancel it. Each design rests on one final write whose interruption recovery always reads as old or new, and on the earlier writes reaching storage before it.

Partial physical data is therefore allowed. What is forbidden is a partial logical result: recovery choosing a state that mixes new data with old, or using data whose write did not finish.

Limits and common mistakes

Leftover partial data must stay unused: a check value must keep recovery from mistaking an incomplete copy for a complete one, and a later operation that reuses the area must erase it first.

Failure atomicity says nothing about threads. A failure-atomic operation can still be observed half done in RAM by another thread running at the same time.

Questions answered

Can partial physical records exist without violating failure atomicity?

Yes. Failure atomicity is a requirement on the state that recovery produces after a failure, which must be exactly the old state or exactly the new one; it does not require storage to be free of incomplete data. For example, a device runs program A with configuration P from slot 0, and power fails while it writes program B with configuration Q into slot 1, which now holds part of B. Recovery reads the commit record, the small stored record that names the current slot, finds slot 0 still named, and starts A with P: the old state, which failure atomicity allows. The partial copy of B is present but never used.

Failure atomicity is violated only if recovery uses partial or mixed data, for example by starting program B with the old configuration P, or by starting from slot 1 although its write never finished. Partial records stay harmless when recovery reads only what the commit record names, every copy carries a check value that exposes an incomplete write, and the commit record is written only after the copy it names is complete.

Related entries: Crash consistency (§8.4), Commit record and selector (§8.21).