sqlite-immutable · shipping · also SQLite immutable=1

SQLite immutable connection

A SQLite immutable connection treats its database file as permanently unchanging and skips locking and change detection.

Related Observatory article: Read on hesela.com

The immutable URI parameter is a caller promise, not a mechanism that freezes a file. It opens the database read-only, but is stronger than mode=ro: another writer must not change the file. Violating the promise can produce incorrect results or SQLITE_CORRUPT. [1]

In a constructed DELETE-journal schedule, an immutable connection kept generation 0 after a writer committed generation 1; a fresh connection saw 1. In the WAL schedule, both retained and fresh immutable connections saw main-file generation 0 while an ordinary reader saw committed generation 2. All those read views passed integrity_check. [3]

Normal read-only WAL access still participates in the WAL protocol. It needs readable sidecar files or permission to create them. Immutable is not a generic workaround for those permissions. For fixed read-only distribution, SQLite recommends preparing the database in DELETE journal mode. [4]

A frozen post-process-exit copy can still require rollback recovery. In Hesela's constructed hot-journal cases on two SQLite builds, immutable access returned all 12 uncommitted records while integrity_check reported ok; ordinary read-only access returned SQLITE_READONLY_ROLLBACK (776). Normal recovery on a separate writable copy restored committed records before immutable access. Unlike the mutable-file cases above, no writer remained alive during these reads. These are software process-exit observations, not physical power-loss tests. [5]

Relations

related
SQLite query_only, SQLite WAL end mark, SQLite integrity_check, Backup verification

Citations

  1. SQLite: URI parameters, mode and immutable (accessed 2026-10-17)
  2. Hesela: measured SQLite reader contracts, nine constructed schedules (accessed 2026-10-17)
  3. Hesela: SQLite immutable-reader observations and provenance (accessed 2026-10-17)
  4. SQLite: Write-Ahead Logging, section 5, read-only databases (accessed 2026-10-17)
  5. Hesela: two-build frozen SQLite crash-copy reader matrix, 400 constructed observations (accessed 2026-11-30)

Further reading

  1. Hesela: native reproduction code, full observations, source receipts and checks (accessed 2026-11-30)
Sources & caveats
  • The mutable cases deliberately violate the API precondition; they are not evidence of a SQLite defect or a guaranteed outcome after misuse. [2]
  • Observed on SQLite 3.45.1 with sequential calls, private caches and mmap disabled. No crash, power loss, network filesystem or physical-I/O tracing. [3]

JSON: /data/terms/sqlite-immutable.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. SQLite immutable connection. Hesela. 2026-11-30. https://hesela.dev/terms/sqlite-immutable/