pub fn open_meta_db(db_path: impl AsRef<Path>) -> Result<Connection>Expand description
Open a SQLite database with Reflex’s standard pragmas.
Every connection to meta.db (and to the symbol cache, which lives in the same
file) MUST go through this helper. Plain Connection::open leaves SQLite at its
defaults, which caused three separate production failures:
- No
busy_timeout— the default is 0, soBEGIN IMMEDIATEreturneddatabase is lockedinstantly whenever the background symbol indexer held a write. Agents saw a raw SQLite error instead of a retry. - No
journal_mode=WAL— readers blocked writers and vice versa, andCacheManager::checkpoint_walwas issuingwal_checkpoint(TRUNCATE)against a rollback-journal database, where it does nothing. - No
foreign_keys=ON— SQLite disables foreign keys per connection by default, so theON DELETE CASCADEclauses in the schema never fired and deleting a row fromfilesorphaned itsfile_branches/file_dependencies/file_exportsrows.
Pragma order is load-bearing: journal_mode=WAL itself can return SQLITE_BUSY
when another connection is attached, so busy_timeout must be set first.
Set REFLEX_SQLITE_JOURNAL=delete to opt out of WAL on network filesystems, where
WAL requires shared-memory support that NFS/SMB do not reliably provide.