Dashboardopencode-loreSQLite reader lifetime and bounded shut…

SQLite reader lifetime and bounded shutdown cleanup

Category: gotcha
Confidence: 1.00
ID: 01a0a0ec-61ae-7402-84cf-73299bd256d6
Project ID: 6f4be9ff-ed84-4cca-a9e7-732a0b0b8677
Cross-project: No
Recalled in other projects: 0
Source session: 0u3imAJmtplig6wtJ
Created: 2026-08-08 12:34:50
Updated: 2026-09-14 17:17:21

Content

Every ReaderConnection must be closed during worker shutdown: a long-lived read mark prevents WAL truncation and previously produced a 5.4 GB WAL. Cleanup must inspect the SQLite singleton directly rather than calling db(), which would open a database while closing or invalidating caches. Set busy_timeout=0, attempt wal_checkpoint(TRUNCATE) best-effort, then close and clear connection/path and vector state. Never let shutdown wait behind a reader; a missed checkpoint is recoverable on reopen.

Move to: