Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(store): checkpoint WAL on close and startup to prevent orphan accumulation (#387)
jjserenitya6ad4011ed1e
diff --git a/src/store/store.c b/src/store/store.cindex f7ed86b4e..d6ae9c277 100644--- a/src/store/store.c+++ b/src/store/store.c@@ -340,6 +340,10 @@ static int configure_pragmas(cbm_store_t *s, bool in_memory) {if (rc != CBM_STORE_OK) {return rc;}+ /* Recover stale WAL from previous crash (best-effort).+ * PASSIVE never blocks readers and never ftruncates.+ * May fail with SQLITE_BUSY if another process holds a lock. */+ (void)sqlite3_exec(s->db, "PRAGMA wal_checkpoint(PASSIVE)", NULL, NULL, NULL);rc = exec_sql(s, "PRAGMA synchronous = NORMAL;");if (rc != CBM_STORE_OK) {return rc;@@ -729,6 +733,12 @@ void cbm_store_close(cbm_store_t *s) {return;}+ /* Checkpoint WAL before close to prevent orphan WAL accumulation.+ * Best-effort — silently skips if concurrent reader holds a lock. */+ if (s->db && s->db_path) {+ (void)sqlite3_wal_checkpoint_v2(s->db, NULL, SQLITE_CHECKPOINT_PASSIVE, NULL, NULL);+ }+/* Finalize all cached statements */finalize_stmt(&s->stmt_upsert_node);finalize_stmt(&s->stmt_find_node_by_id);