Skip to main content

Module sqlite_store

Module sqlite_store 

Source
Expand description

A small SQLite store for the post-processor’s on-disk caches: a file, or an in-memory database when there is no file to keep or it cannot be used.

WAL journal (the file’s own mode where WAL cannot be set: a network filesystem, or one without shared memory, FUSE, CIFS, WSL’s /mnt), synchronous=NORMAL (in WAL no sync per commit, and a crash never corrupts the file), a busy timeout, and a user_version gate: a file made for another schema, or another program’s database, is left alone; a new file gets its schema under the write lock. Opening is retried while another process holds the file: turning a new file to WAL meets a lock the busy timeout does not wait on (SQLite returns SQLITE_BUSY at once to avoid a deadlock). Writers take one IMMEDIATE transaction per allocation (SqliteStore::immediate), so processes sharing the file serialize on it. A store is opened lazily by its owner and never kept in a static (a forked process must not inherit the connection). Failure policy, opening, reading or writing: a Warning, then the rest of the run in memory (SqliteStore::fell_back), from a copy of what the file held when it gives it at once and the copy works.

Structs§

SqliteStore
An open store: its connection and the file it reads, when not in memory.