CS PAPERS DEEP-READ · PAPER 60

ARIES: Database Crash Recovery

Mohan, Haderle, Lindsay, Pirahesh, Schwarz · IBM Almaden · ACM TODS 1992

中文 →

What did this paper do?

You tap "confirm transfer" and the screen says "done." If the data center loses power one second later, could half the money vanish — debited from one account and never credited to the other? It can't. And that confidence comes in large part from ARIES, published in 1992 by a team at IBM. It took "how to tidy up the books after a crash" from a pile of house-specific folk remedies and turned it into one standard method you can explain, argue about, and copy. Most databases you touch today still run on its skeleton.

First, how hard this is

A database doesn't write each change straight to disk — far too slow. It changes things in memory, lets them pile up, and writes whole blocks back later. So at the instant the power dies, the disk holds a half-cooked mess: some transactions already told the user "done" while their changes still sit in memory (lost); others got only halfway and never committed, yet the memory they dirtied happened to be flushed to disk anyway (dirty). Both kinds coexist, tangled together on the same page.

The one core move: write the diary before the ledger

ARIES rests on a rule so plain it sounds boring: before touching the ledger, write down what you are about to do in a diary, and make sure that diary entry reaches disk first. The diary is append-only, never erased — "I changed that number on page 7 from 3 to 5." With it, the half-cooked mess is salvageable: whatever the diary records but the ledger lacks gets redone; whatever traces a half-finished transaction left behind get undone by working backwards. And the diary is written sequentially, which is far faster than scribbling in a dozen scattered spots of the ledger.

Three details that make redo and undo actually safe

1. Number every diary entry, and stamp every ledger page. Each page carries a line in its header: "I was last modified by diary entry 42." Hold diary entry 57 against it: the stamp says 42, earlier than 57, so this change hasn't landed on this page yet — redo it. If the stamp already says 90, it was applied long ago — skip. So redoing ten times gives the same result as redoing once, which matters enormously, because the power can die again mid-recovery and the whole thing starts over.

2. Replay history exactly, then undo. Recovery doesn't sort the good from the bad. It replays the diary end to end exactly as written — including changes made by the doomed half-finished transactions — restoring the database to precisely how it looked the instant before the crash, and only then cleanly undoes those half-finished transactions. Why the extra step? Because undo is an action with preconditions: to erase a record you first have to know where it is and what surrounds it. Redo only the "good" changes and the database lands in a strange state that never actually existed. It's forensic practice: put the scene back exactly as the photographs show it, then reason backwards step by step.

3. Undo itself gets written into the diary. Each time it undoes a step, it adds an entry: "just undid that one; the next one to undo is number N." If the power dies halfway through the rollback, on restart the last such entry says exactly where to resume — everything already undone is skipped wholesale and never undone twice. That is precisely what guarantees that repeated crashes still converge.

What it buys

With all this in place, a database can finally treat memory as memory: dirty data can be flushed whenever convenient (even for a transaction that hasn't committed), and a commit needn't wait for the data to land on disk — only the diary entry. Fast, and unafraid of power failure. The cost is real too: every change is written twice, so this diary becomes the busiest single lane in the system — and in the age of many-core in-memory databases, it turned into the new bottleneck.

Remember one thing

Before touching data, write the change into an append-only diary and get it on disk. After a crash, the "last modified by entry N" stamp on each page turns redo into an action that's safe to repeat any number of times; replay all of history exactly to restore the scene, then go back and undo the half-finished transactions — logging each undo step too. So no matter which instant the power dies again, recovery can pick up where it left off and is guaranteed to finish the cleanup.

Want the three-pass diagram, the CLR pointer chain, and the steal / no-force trade-off? → switch to the deep read