Crash Recovery and Write-Ahead Logging · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Log first, so crashes lose nothing promised

Computing · Data & Databases · ages 20-22
Name ______________________   Date ____________
  1. After a crash, committed work is replayed and uncommitted partial work is removed.

    Circle one:   True   False

  2. What is written first when a transaction changes data?

    • The change to the data page
    • The intention in the log
    • The commit record
  3. When is the commit record written?

    • After every change of the transaction sits safely in the log
    • Before anything is written anywhere
    • Only during a checkpoint
  4. Why must the log live on safe storage ahead of the pages?

    • Logs are prettier than pages
    • Pages cannot be written at all
    • Pages can be lost in a crash while the log survives
  5. The log ends mid-transaction with no commit record. What happens to its partial changes?

    • They are replayed as if committed
    • They are rolled back and removed
    • They are left half written forever
  6. What does a checkpoint do?

    • Writes pending changes to pages and notes the spot in the log
    • Deletes the entire log
    • Commits every open transaction at once
  7. A friend writes data pages first and the log afterwards. What breaks?

    • Nothing, the order makes no difference
    • Checkpoints become slightly slower
    • A crash between the two leaves work that cannot be rebuilt
  8. A log holds T1 with a commit record and T2 without one. What does recovery do?

    • Redoes T1 step by step and undoes the partial T2
    • Undoes both transactions fully
    • Redoes both transactions fully
LightMySky · lightmysky.comW1-mt_JFPafSWOWF-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Log first, so crashes lose nothing promised W1-mt_JFPafSWOWF-s1

  1. True · Redo rebuilds the promised work, undo wipes the unfinished rest.
  2. The intention in the log · The log record comes first, then the page change, then the commit record.
  3. After every change of the transaction sits safely in the log · Commit waits until the whole intention is safe in the log.
  4. Pages can be lost in a crash while the log survives · Rebuilding is possible only because the surviving log holds every intention.
  5. They are rolled back and removed · Without a commit record the work never happened, so undo cleans it up.
  6. Writes pending changes to pages and notes the spot in the log · Checkpointing pushes pages up to date so recovery starts from that spot.
  7. A crash between the two leaves work that cannot be rebuilt · Lost pages with no logged intention are gone, since the log is the only rebuild source.
  8. Redoes T1 step by step and undoes the partial T2 · The commit record is the divider: T1 is promised, T2 never happened.
Worksheet · LightMySky