{"record":{"id":"a7d7314e9109f125","repo":"Hmbown/CodeWhale","slug":"state-db-connection-mutex-poisoned","errorCode":null,"errorMessage":"state db connection mutex poisoned","messagePattern":"state db connection mutex poisoned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/state/src/lib.rs","lineNumber":357,"sourceCode":"                    db_path.display()\n                );\n            }\n        }\n        Ok(())\n    }\n\n    /// Returns the filesystem path of the underlying SQLite database.\n    pub fn db_path(&self) -> &Path {\n        &self.db_path\n    }\n\n    fn conn(&self) -> Result<MutexGuard<'_, Connection>> {\n        // Poisoning means a panic mid-operation; any open transaction was\n        // rolled back when it dropped, but surface the condition rather than\n        // silently continuing on a connection whose state we can't vouch for.\n        self.conn\n            .lock()\n            .map_err(|_| anyhow::anyhow!(\"state db connection mutex poisoned\"))\n    }\n\n    fn init_schema(conn: &Connection) -> Result<()> {\n        let mut user_version: u32 = conn.query_row(\"PRAGMA user_version;\", [], |row| row.get(0))?;\n        if user_version == 0 {\n            // Guard each ALTER: a database restored with a v0 header (or\n            // stamped by a racing process that crashed before setting\n            // user_version) can already carry these columns, and an\n            // unguarded ADD COLUMN aborts the whole open with\n            // \"duplicate column name\".\n            let add_parent_entry_id = if column_exists(conn, \"messages\", \"parent_entry_id\")? {\n                \"\"\n            } else {\n                \"ALTER TABLE messages ADD COLUMN parent_entry_id INTEGER NULL;\"\n            };\n            let add_current_leaf_id = if column_exists(conn, \"threads\", \"current_leaf_id\")? {\n                \"\"\n            } else {","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/state/src/lib.rs#L339-L375","documentation":"Error \"state db connection mutex poisoned\" thrown in Hmbown/CodeWhale.","triggerScenarios":"Thrown at crates/state/src/lib.rs:357 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}