Crash Recovery

Why Recovery is Needed?


Log Sequence Numbers (LSN)

Definition:

Types of LSNs

LSN Type Where Stored Description
flushedLSN Memory Last LSN that was flushed to disk
pageLSN Data Page Newest update LSN for a page
recLSN Data Page Oldest LSN that dirtied the page
lastLSN Active Transaction Table Last LSN of a transaction
MasterRecord Disk LSN of the latest checkpoint

Writing Log Records

  1. Each data page contains a pageLSN (most recent update).
  2. The system tracks flushedLSN (max LSN flushed to disk).
  3. Before writing a page to disk, WAL ensures:
pageLSN <= flushedLSN

(Ensuring the log is written before the page is modified.)

Rule: The log record must be written before the actual page update.