WAL Recovery
Lesson, slides, and applied problem sets.
View SlidesLesson
WAL Recovery (Redo/Undo)
Why this module exists
Crashes happen. Recovery is the proof that your durability and atomicity rules are correct. This module makes recovery explicit: analyze the log, redo changes, and undo uncommitted work.
1) Redo phase
Redo replays all updates in LSN order but only applies those newer than the pageLSN.
This makes recovery idempotent: you can replay the log multiple times without corrupting data.
2) Undo phase
Undo reverses updates from uncommitted transactions by applying their before-images in reverse LSN order.
In full ARIES, undo is logged with compensation records (CLRs). In this pack, we model undo directly to emphasize the concept.
3) Analysis phase
We must identify:
- which transactions committed
- which are still active at crash time
This determines which updates to undo.
What you will build
- A recovery routine that performs analysis, redo, and undo on a toy page store.
Key takeaways
- Redo is ordered by LSN and guarded by pageLSN.
- Undo is applied only to uncommitted work.
- Recovery is a deterministic transformation of log + pages.