{"record":{"id":"e733991e67001463","repo":"linera-io/linera-protocol","slug":"failed-to-check-sqlite-database-existence-file","errorCode":null,"errorMessage":"failed to check SQLite database existence. file: {database_url}, error: {e}","messagePattern":"failed to check SQLite database existence\\. file: (.+?), error: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-indexer/lib/src/db/sqlite/mod.rs","lineNumber":80,"sourceCode":"}\n\nimpl SqliteDatabase {\n    /// Creates a new SQLite database connection.\n    pub async fn new(database_url: &str) -> Result<Self, SqliteError> {\n        if !database_url.contains(\"memory\") {\n            match std::fs::exists(database_url) {\n                Ok(true) => {\n                    tracing::info!(?database_url, \"opening existing SQLite database\");\n                }\n                Ok(false) => {\n                    tracing::info!(?database_url, \"creating new SQLite database\");\n                    // Create the database file if it doesn't exist\n                    std::fs::File::create(database_url).unwrap_or_else(|e| {\n                        panic!(\"failed to create SQLite database file: {database_url}, error: {e}\")\n                    });\n                }\n                Err(e) => {\n                    panic!(\n                        \"failed to check SQLite database existence. file: {database_url}, error: {e}\"\n                    )\n                }\n            }\n        }\n        let pool = SqlitePoolOptions::new()\n            .max_connections(5)\n            .connect(database_url)\n            .await\n            .map_err(SqliteError::Database)?;\n        let db = Self { pool };\n        db.initialize_schema().await?;\n        Ok(db)\n    }\n\n    /// Initialize the database schema\n    async fn initialize_schema(&self) -> Result<(), SqliteError> {\n        // Create core tables","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-indexer/lib/src/db/sqlite/mod.rs#L62-L98","documentation":"Before creating or opening its SQLite file, the indexer probes whether the path exists; if that probe itself returns an error (as opposed to a clean yes/no), the constructor panics. This means the filesystem could not answer 'does this file exist' — typically because a path component is unreadable, a component is a plain file rather than a directory, or the path traverses a directory without search (execute) permission.","triggerScenarios":"Database path like /root/data/indexer.db when /root is mode 700 and the process runs as another user; a path component that is a regular file (e.g. data.txt/indexer.db); path on a failing/unmounted NFS or FUSE mount. Distinguished from error 21: here the stat/existence check fails, not the create.","commonSituations":"Running under a container service account with restricted home directories; stale absolute paths baked into config files after a directory layout change; security-hardened systems with restrictive parent-directory modes.","solutions":["Verify each component of the path is a directory and traversable: namei -l /path/to/indexer.db shows the first failing component","Fix permissions on the failing component (chmod o+x or chown) or choose a path you fully own","Remove stale file-where-a-directory-is-expected components","If on a network mount, ensure it is mounted and healthy before starting the indexer"],"exampleFix":"# before (parent dir not traversable by the service user)\nsudo -u indexer linera-indexer --database /home/deploy/indexer.db\n\n# after\nsudo mkdir -p /var/lib/linera-indexer && sudo chown indexer /var/lib/linera-indexer\nsudo -u indexer linera-indexer --database /var/lib/linera-indexer/indexer.db","handlingStrategy":"validation","validationCode":"let path = std::path::Path::new(database_url);\nfor ancestor in path.ancestors().skip(1) {\n    match std::fs::metadata(ancestor) {\n        Ok(md) if md.is_dir() => {}\n        Ok(_) => panic!(\"{ancestor} is a file, not a directory\"),\n        Err(e) => panic!(\"cannot stat {ancestor}: {e}\"),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check traversability of every path component with namei -l when provisioning","Avoid database paths that traverse other users' home directories","Mount and verify network volumes before starting the service"],"tags":["sqlite","indexer","filesystem","permissions","startup"],"backgroundTag":"file-access-denied","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}