Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 07 · From Scratch · Database · with code: Go · about 26 min to read

Play it as a journeyTutor comes with a plan

Write-Ahead Log

Write-Ahead Log
Write-Ahead Log · Open board

Follows Database 04: The B-Tree, and

Before you start. This series builds a small copy of a database, a program that stores your data and can find any piece of it again fast, the way a real database does. So far, it stores rows inside fixed-size chunks called pages, and it finds any row quickly using a B-tree, a sorted tree built out of those pages.

Lesson 50 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1992: IBM needs a bank’s records to never half-happen
  • The rule: write the plan down, then act
  • The failure this is actually defending against
  • What fsync actually promises
  • A second, quieter failure: the torn page
  • The record format
  • The log writer
  • The commit path
  • Recovery
  • Kill it and see
  • Checkpoints, and why the log can’t just grow
  • What a real engine adds
  • The log is also the stream
  • The one thing

Terms it explains: write-ahead log, WAL, fsync, commit record, crash recovery, redo, power cut, delta, group commit, idempotent, SIGKILL, The log grows forever, checkpoint, bigger, write-behind, absolute new value.

Related paper

Review From Scratch