{"record":{"id":"e4482f6e749417b8","repo":"tinyhumansai/openhuman","slug":"stale-sqlite-side-file-present-may-indicate-uncle","errorCode":null,"errorMessage":"stale SQLite side-file present (may indicate unclean shutdown): {}","messagePattern":"stale SQLite side-file present \\(may indicate unclean shutdown\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/platform/doctor/core.rs","lineNumber":805,"sourceCode":"/// - If the DB directory / file does not exist yet: `Warn` (not yet created).\n/// - If a stale `.db-shm` file is present alongside the DB: `Warn`.\n/// - If we can open the DB and run a basic probe query: `Ok`.\n/// - If the probe fails: `Error`.\nfn check_memory_tree_db(config: &Config, items: &mut Vec<DiagnosticItem>) {\n    let cat = \"memory_tree_db\";\n    let db_path = config.workspace_dir.join(\"memory_tree\").join(\"chunks.db\");\n\n    // ── Stale side-files (checked even when chunks.db is absent) ────\n    let base_name = db_path\n        .file_name()\n        .unwrap_or_default()\n        .to_string_lossy()\n        .into_owned();\n    let shm = db_path.with_file_name(format!(\"{base_name}-shm\"));\n    let wal = db_path.with_file_name(format!(\"{base_name}-wal\"));\n    for sidecar in [&shm, &wal] {\n        if sidecar.exists() {\n            items.push(DiagnosticItem::warn(\n                cat,\n                format!(\n                    \"stale SQLite side-file present (may indicate unclean shutdown): {}\",\n                    sidecar.display()\n                ),\n            ));\n        }\n    }\n\n    // ── File existence ──────────────────────────────────────────────\n    if !db_path.exists() {\n        items.push(DiagnosticItem::warn(\n            cat,\n            format!(\n                \"DB not yet created (first ingest will initialise it): {}\",\n                db_path.display()\n            ),\n        ));","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/platform/doctor/core.rs#L787-L823","documentation":"Doctor memory-tree check: a chunks.db-shm or chunks.db-wal sidecar exists next to the SQLite database. SQLite deletes these on clean shutdown; a surviving -shm/-wal pair means the last process died without closing the DB (crash, kill -9, power loss). The data is normally recovered by WAL replay on next open, but the flag warns that unclean shutdown occurred and, if a stale process still holds the file, locking issues are possible.","triggerScenarios":"Thrown at src/openhuman/platform/doctor/core.rs:805 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Open the core once so SQLite replays the WAL and removes the sidecars cleanly","If sidecars persist after a clean shutdown, no process may be holding the DB — stop all core instances and delete the -shm/-wal pair only after backing up chunks.db","Investigate the cause of the unclean shutdown (OOM killer, forced quit) to avoid WAL corruption"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}