Summarizing ARIES recovery and redo rationale
The ARIES recovery has three phases: analysis rebuilds transaction and dirty page tables from the checkpoint; redo replays all updates from the earliest dirty page LSN to restore pages to the crash state—even for loser transactions—to ensure data consistency amid steal/no-force and fuzzy checkpoints; undo rolls back loser transactions using compensation log records. Redo replays all history so the database reaches its exact pre-crash state, enabling correct undo and simplifying concurrency, while PageLSN on each page ensures idempotent reapplication by skipping already applied updates.
ARIES sits on top of write–ahead logging, a steal/no‑force buffer manager and “fuzzy” checkpoints, so it cannot assume very much about what was in the database at the point of failure. Recovery is therefore organised into three passes over the log:
-
In the analysis pass the system replays the end‑of‑checkpoint record and scans forward to reconstruct the transaction table and dirty‑page table as they were at the crash. From the dirty‑page table it can compute the smallest recLSN, the point in the log where a page was first dirtied. That becomes the starting point for redo.
-
The redo pass is “repeat history”: scan forward from the RedoLSN and for each update log record decide whether the corresponding page is dirty and whether that log record’s effects are already on disk. If not, the change is applied. Compensation log records generated by previous undos are also redone. This pass does not stop at committing transactions; it replays losers’ actions as well.
-
In the undo pass the system walks backwards through the log for all loser transactions, generating compensation log records (CLRs) as it undoes each change. CLRs contain an UndoNextLSN so that if recovery itself fails, a subsequent redo will replay the CLRs and resume undo from the right place. CLRs are “redo‑only” and are never undone themselves.
The reason redo “replays history” including work that will ultimately be rolled back is that after a crash the on‑disk pages are a mixture of states: some updates from loser transactions may already be present, others may have been lost in the buffer pool. Bringing every page back to the exact state it had at the moment of the crash simplifies the subsequent undo and avoids having to reason about which structural changes have or have not been applied. Once that crash‑time state has been reconstructed, the losers can be cleanly undone.
Idempotence is ensured by log sequence numbers. Every log record is assigned an increasing LSN, and each data page stores the PageLSN of the last log record applied to it. During redo a log record is only reapplied if its LSN is greater than the page’s PageLSN (and the page was dirty at or before that LSN). If the page already reflects that change, it is skipped. This “LSN check” makes repeated redo safe and allows ARIES to reprocess CLRs and other updates without duplicating their effects.