Part 4 of 5 · 2 min read
The undo phase
Only now, with the database restored to its exact crash-moment state, are the uncommitted transactions' changes reverted.
The undo phase
Think of the inspector's crew, having restored the site to exactly how it looked the moment the evacuation happened. The crew now goes back specifically to the rooms flagged as mid-renovation and reverses just those changes, leaving the finished rooms untouched.
In plain words: only after redo has restored the database to its exact crash-moment state does the undo phase begin, reverting the changes made by whichever transactions analysis identified as still active, not yet committed, at the time of the crash. This ordering, redo everything, then undo only the uncommitted, is the specific sequence that gives ARIES its name: analysis, redo, undo, in that fixed order. Once undo finishes, the database is left in a state consistent with only the transactions that had actually committed before the crash, exactly satisfying atomicity and durability together.
A worked example. Undo reverts transaction B's change, using the recorded old value exactly as covered on the write-ahead-log page, leaving the database reflecting only transaction A's committed change, the correct final state after recovery.
The key lines. No new SQL; undo in ARIES operates exactly as covered on the write-ahead-log page, but now running only after the redo phase has already completed in full.
Undo phase (ARIES)
The undo phase in ARIES runs after redo has restored the database's exact crash-moment state, reverting only the changes of transactions analysis identified as uncommitted, leaving a final state consistent with just the committed transactions.
Example: going back to reverse only the rooms flagged as mid-renovation, after the whole site was first restored to match the records exactly, mirrors ARIES's undo phase.
Remember this
ARIES runs analysis, then redo, then undo, always in that fixed order. The deliberate choice to redo everything before undoing anything is what makes the algorithm simpler and well-defined, rather than needing to determine commit status before redo ever begins.
Quick notes
- ARIES has three phases, always run in this order: analysis, redo, undo.
- Analysis scans the log from the last checkpoint to determine which transactions need undoing, without changing any data.
- Redo reapplies every logged change unconditionally, regardless of commit status, restoring the exact crash-moment state.
- Undo then reverts only the changes belonging to transactions that never committed.
- Redoing everything before undoing anything is a deliberate design choice that keeps the algorithm simpler.