Checkpoint starvation
Checkpoint starvation is sustained inability to finish or reset a database log checkpoint because the required progress conditions keep being obstructed.
In SQLite WAL, retained reader snapshots can constrain backfill and recycling while later writes continue. [1] A two-case observation separates a pinned transaction from an idle open connection; it is not a production failure-rate study. [4] A PASSIVE result can report busy=0 with fewer checkpointed frames than current log frames. [2]
A completed or cancelled backup can leave a source read that the caller opened earlier. In 84 synthetic runs on two builds, that read retained WAL history after backup cleanup; a reader-only control did the same. BEGIN alone did not pin a read between steps. Per-schema transaction state distinguishes it from BEGIN plus SELECT. [5] [7]
journal_size_limit=0 did not cap the live WAL in those fixtures: required frames remained until the owned read ended. The setting controls retained file size around reset, not an unconditional quota. File length is not physical I/O or a timing measurement. [6] [8]
Ending starvation is not history erasure. In a separate SQLite 3.45.1 deletion fixture with core secure_delete ON, a pinned reader caused a busy TRUNCATE result. After reader release, FULL and RESTART completed but retained the deleted token in the WAL. Successful TRUNCATE shortened that logical file to zero; an earlier backup still returned the original row. These are stages of one controlled lifecycle, not independent trials or a media-sanitization test. [10]
RESTART prepares the log for reuse by the next writer; TRUNCATE additionally shortens it on success. Historical WAL bytes need not survive reuse indefinitely. Do not delete a live WAL manually. [9] [1]
close_v2 can retain a reader. [13]
Relations
- related
- Database checkpoint, Write-ahead log, SQLite WAL end mark, SQLite Online Backup API, SQLite transaction state, SQLite snapshot handle
Limitations
- A large WAL file alone does not identify starvation; file length can remain high after progress. [1]
- Checkpoint counters include earlier backfill, not just new work per call. [9]
- WAL frame validity requires matching salts and cumulative checksums; stored residue alone does not establish replay eligibility. [12]
- An unfinalized statement can delay destruction without pinning a snapshot: unstepped, drained and reset SELECT controls allowed TRUNCATE in the recorded fixtures. [14]
Citations
- SQLite: Write-Ahead Logging, sections 2, 6 and 11
- SQLite: PRAGMA wal_checkpoint, three-column result
- Hesela: measured SQLite WAL-reader observations and limits
- Hesela: two-build source-read retention experiment, derived summary and receipt hashes
- SQLite: PRAGMA journal_size_limit, retained file size and reset
- SQLite: per-schema transaction state
- Hesela: source-read ownership after backup cleanup, method and limitations
- SQLite: checkpoint modes, completion and truncation
- Hesela: generated SQLite deletion observations, two retained runs and explicit limits
- SQLite Database File Format: WAL frame validity and reset (sections 4.1 and 4.4)
- SQLite C API: closing a connection and deferred destruction
- Hesela: twelve native close-lifecycle schedules on each of two SQLite builds
- Hesela: separate native C verification of the existing close-lifecycle schedules
Further reading
- SQLite WAL checkpoint starvation: success is not completion
- Hesela: standalone SQLite deletion evidence, code and 42 raw files
- Hesela: SQLite close-lifecycle sources, raw observations and replay code
- Hesela: both close-lifecycle observers, retained results and source snapshots
Sources & caveats
- The deletion fixture does not run a subsequent writer/reset; residue after reuse was not measured. [10]
- Twelve native C-API schedules per build on SQLite 3.45.1 and 3.54.1; an active SELECT prevented TRUNCATE completion after close_v2 returned OK. No crash, performance or failure-rate measurement. [14]
- A separate C observer matched all 48 executions (12 schedules, two recorded engine binaries, two harness compiler modes). Same host and binaries, with the earlier packet visible; not external peer review, field samples or power-loss evidence. [16]