SQLite WAL end mark
A SQLite WAL end mark is the committed WAL boundary that determines which page versions a read transaction may observe.
The transaction's snapshot does not advance when another connection commits. Ending the transaction and starting another permits a newer view. [1] Distinguish this logical snapshot boundary from the shared WAL-index read-mark slots and locks used by checkpoint coordination. They are related mechanisms, not interchangeable counters. [2] Complete-row comparisons check the retained generation and the newer state after release. [4]
A source connection's retained read view can also bound an online backup. Hesela measured a completed generation-1 copy after generation 2 had committed; releasing the old snapshot allowed the current generation in the tested schedule. Backup completion and integrity did not establish freshness. [5]
Space accounting also follows the read view. In a synthetic 512-byte-page control, an old transaction saw 96 rows and 300 dbstat pages while the current one saw 24 rows and 77 pages against identical main/WAL captures. dbstat excludes freelist, pointer-map and lock-byte pages. Aggregate mode emits one row per B-tree: count(*) then counts trees, while sum(pageno) counts their pages. In normal mode pageno is a page identifier, not an additive page count. A monitoring transaction should be short because its own retained read view can delay checkpoint progress. [6] [8] [1]
WAL file length does not identify its current generation. In the 4,096-byte control, reuse left a 412,032-byte WAL with 100 physical frame slots but only one valid committed frame. Header salts and cumulative checksums delimit valid frames; the reader end mark then bounds visibility within that generation. [6] [9]
Relations
- related
- Write-ahead log, Database checkpoint, Checkpoint starvation, SQLITE_BUSY_SNAPSHOT, Backup verification, SQLite immutable connection, SQLite query_only, SQLite data_version, SQLite snapshot handle
Limitations
- An open connection does not itself identify the lifetime or contents of an active read snapshot. [1]
Citations
- SQLite: Isolation, WAL snapshots and transaction lifetime
- SQLite: WAL-mode File Format, WAL-index header and read marks
- Hesela: measured SQLite WAL-reader observations and limits
- Hesela: SQLite backup source-snapshot observations
- Hesela: SQLite space accounting, 32 synthetic observations and method
- Hesela: reproducible SQLite space-accounting code, tests and raw captures
- SQLite: DBSTAT populations and aggregate mode
- SQLite file format: WAL reset, salts and frame validity
Further reading
Sources & caveats
- Four serialized synthetic configurations, eight states each; not independent field samples. Explicit secure_delete=ON aligns recorded 3.45.1 and 3.53.1 semantic/format rows. File lengths do not measure physical writes. [6]
- Reproduction code, all 64 primary main/WAL captures and the documented initial default mismatch are retained together. [7]