Kestrel Docs

SQLite WAL Mode & Checkpoint Mechanics

Write-Ahead Logging (WAL) fundamentally changes how SQLite handles concurrent reads and writes. Instead of mutating pages in the main database file while recording rollback journals, new page versions are appended sequentially to an auxiliary -wal file.

Concurrency Guarantees

Under WAL mode, readers do not block writers and writers do not block readers. Each reader records an end-mark in the shared-memory index (-shm) and ignores frames appended after its transaction began.

Production PRAGMA Baseline

PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA busy_timeout = 5000;
PRAGMA cache_size = -64000;
PRAGMA foreign_keys = ON;
PRAGMA temp_store = MEMORY;

Preventing Unbounded WAL Growth

By default, SQLite triggers a passive auto-checkpoint after 1000 pages. However, a single long-running read transaction can pin the WAL read mark and prevent checkpointing from resetting the log back to frame zero. Keep read transactions short and monitor -wal file size in your metrics collector.