{"record":{"id":"40d6e4f16e70d924","repo":"datahaven-xyz/datahaven","slug":"failed-creating-sql-backend","errorCode":null,"errorMessage":"failed creating sql backend: {:?}","messagePattern":"failed creating sql backend: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"operator/node/src/service.rs","lineNumber":255,"sourceCode":"            let overrides = Arc::new(StorageOverrideHandler::new(client.clone()));\n            let sqlite_db_path = frontier_database_dir(config, \"sql\");\n            std::fs::create_dir_all(&sqlite_db_path).expect(\"failed creating sql db directory\");\n            let backend = futures::executor::block_on(fc_db::sql::Backend::new(\n                fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {\n                    path: Path::new(\"sqlite:///\")\n                        .join(sqlite_db_path)\n                        .join(\"frontier.db3\")\n                        .to_str()\n                        .expect(\"frontier sql path error\"),\n                    create_if_missing: true,\n                    thread_count: eth_config.frontier_sql_backend_thread_count,\n                    cache_size: eth_config.frontier_sql_backend_cache_size,\n                }),\n                eth_config.frontier_sql_backend_pool_size,\n                std::num::NonZeroU32::new(eth_config.frontier_sql_backend_num_ops_timeout),\n                overrides.clone(),\n            ))\n            .unwrap_or_else(|err| panic!(\"failed creating sql backend: {:?}\", err));\n            fc_db::Backend::Sql(Arc::new(backend))\n        }\n    };\n\n    Ok(frontier_backend)\n}\n\nfn build_babe_inherent_providers(\n    slot_duration: sp_consensus_babe::SlotDuration,\n    use_mock_timestamp: bool,\n) -> (\n    sp_consensus_babe::inherents::InherentDataProvider,\n    sp_timestamp::InherentDataProvider,\n) {\n    if use_mock_timestamp {\n        // In manual/instant sealing we want to advance time deterministically per block\n        // to satisfy `pallet_timestamp` MinimumPeriod without sleeping. We increment a\n        // static counter by one slot each time and use that value as the timestamp.","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/datahaven-xyz/datahaven/blob/edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec/operator/node/src/service.rs#L237-L273","documentation":"This panic occurs in open_frontier_backend when fc_db::Backend::Sql fails to initialize the Frontier SQL backend (used by the EVM RPC layer to expose blockchain data over SQL). The backend needs a working database connection, a valid cache size, pool size, and operation timeout; any failure there is unrecoverable at node startup, so the code panics via unwrap_or_else. Since it is a panic (not a Result), the node process aborts during startup.","triggerScenarios":"Calling new_partial (and thus open_frontier_backend) when the frontier-sql backend cannot be created: database unreachable/wrong connection settings, invalid frontier_sql_backend_cache_size, frontier_sql_backend_pool_size, or frontier_sql_backend_num_ops_timeout values, or incompatible schema/overrides.","commonSituations":"Running the node with frontier-sql enabled but the database service down or misconfigured (wrong host/port/credentials), pool_size or timeout set to zero or overflowing NonZeroU32 values, or stale SQL schema after upgrading Frontier versions.","solutions":["Verify the SQL database (e.g. PostgreSQL) is running and reachable with the configured connection settings.","Check that frontier_sql_backend_pool_size and frontier_sql_backend_num_ops_timeout are non-zero positive integers (they are converted via NonZeroU32).","Review the debug-printed error ({:?}) in the panic message for the underlying cause (connection refused, auth failure, schema error).","If the schema is incompatible after a Frontier upgrade, recreate/migrate the database schema.","If SQL backend is not needed, switch the CLI config to the in-memory (KeyValue) frontier backend instead."],"exampleFix":"// before\neth_config.frontier_sql_backend_pool_size = 0;\n// after\neth_config.frontier_sql_backend_pool_size = 5; // must be a non-zero u32","handlingStrategy":"try-catch","validationCode":"// preflight: check DB reachable and settings sane before building the node\nif (pool_size == 0 || num_ops_timeout == 0) panic!(\"frontier sql pool size and ops timeout must be non-zero\");\nTcpStream::connect((db_host, db_port)).expect(\"frontier SQL backend database unreachable\");","typeGuard":"fn valid_sql_backend_config(cache: u32, pool: u32, timeout: u32) -> bool {\n    NonZeroU32::new(pool).is_some() && NonZeroU32::new(timeout).is_some() && cache > 0\n}","tryCatchPattern":"// panic is fatal; catch at process supervisor level\nmatch open_frontier_backend(&config) {\n    Ok(backend) => backend,\n    Err(e) => { log::error!(\"frontier sql backend init failed: {:?}\", e); std::process::exit(1); }\n}","preventionTips":["Health-check the database as a startup dependency before launching the node.","Validate pool size and timeout are positive in CLI config parsing.","Log the underlying error before panicking so operators see the root cause.","Pin Frontier versions and rerun schema migrations after upgrades."],"tags":["database","startup","config","panic"],"backgroundTag":"database-query-failed","analyzedSha":"edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec","analyzedAt":"2026-09-13T19:19:32.206Z","contentChangedAt":"2026-09-13T19:19:32.206Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}