Avoid mixed SQLite access during TUI startup#417
Conversation
Issue #401 shows TUI startup rebuilding the analytics cache while another writer is active, with DuckDB and go-sqlite3 both in the crash stack. The TUI should not overlap its long-lived Store or background FTS maintenance with DuckDB sqlite_scanner access to the same database file. Run the automatic cache rebuild before opening the TUI Store, start background FTS only after the query engine is initialized, and default the interactive DuckDB engine to the direct SQLite fallback for detail reads. This matches the daemon-side constraint that keeps DuckDB's bundled SQLite from attaching a live msgvault database inside a process that also owns go-sqlite3 connections. Generated with Codex Co-authored-by: Codex <codex@openai.com>
roborev: Combined Review (
|
The first pass for issue #401 moved automatic cache export before the long-lived TUI Store existed, but it also moved the export ahead of InitSchema/runStartupMigrations and left a second post-open build block behind. That could fail on upgraded SQLite databases whose cache-export columns are added by startup migrations, or retry the DuckDB export while the TUI Store was already open. Keep the mixed-SQLite avoidance invariant by using a short-lived migrated store first, closing it before any cache export, and reopening the migrated store for the interactive TUI. The TUI now has one cache-build point, after migrations and before the long-lived Store is used by the query engine. Generated with Codex Co-authored-by: Codex <codex@openai.com>
|
Addressed the review finding in a28897d. TUI startup now opens a short-lived store to run InitSchema/startup migrations, closes it before any DuckDB cache export, performs at most one cache build, then reopens the migrated store for the interactive TUI. The linked CI job failed while exporting Docker Buildx cache ( |
roborev: Combined Review (
|
Issue #401 exposed a TUI startup crash while
msgvault syncwas active: the process could rebuild the Parquet cache through DuckDB while also holding go-sqlite3 connections and starting background FTS maintenance. That repeats the same mixed-SQLite-library risk already documented for daemon cache rebuilds, where DuckDB's bundled SQLite should not attach the live database inside a process that also owns normal msgvault SQLite connections.This changes interactive startup so the automatic cache build runs before the long-lived TUI store is opened, and FTS maintenance starts only after the query engine is initialized. The DuckDB-backed TUI engine also defaults to direct SQLite fallback for detail reads instead of attaching the live database through
sqlite_scanner, preserving fast Parquet aggregates without keeping two SQLite implementations attached to the same WAL database in the interactive process.The regression coverage locks in that TUI DuckDB options keep
sqlite_scannerdisabled by default. Standard Go formatting, vetting, and full tagged tests pass locally.