{"record":{"id":"396d6eadb34f088a","repo":"FuelLabs/fuel-core","slug":"off-chain-database-is-already-initialized","errorCode":null,"errorMessage":"Off chain database is already initialized","messagePattern":"Off chain database is already initialized","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/service/genesis.rs","lineNumber":88,"sourceCode":"\n/// Performs the importing of the genesis block from the snapshot.\npub async fn execute_genesis_block(\n    watcher: StateWatcher,\n    config: &Config,\n    db: &CombinedDatabase,\n) -> anyhow::Result<UncommittedImportResult<Changes>> {\n    let genesis_block = create_genesis_block(config);\n    tracing::info!(\"Genesis block created: {:?}\", genesis_block.header());\n    let on_chain = db\n        .on_chain()\n        .clone()\n        .into_genesis()\n        .map_err(|_| anyhow::anyhow!(\"On chain database is already initialized\"))?;\n    let off_chain = db\n        .off_chain()\n        .clone()\n        .into_genesis()\n        .map_err(|_| anyhow::anyhow!(\"Off chain database is already initialized\"))?;\n\n    let genesis_db = CombinedGenesisDatabase {\n        on_chain,\n        off_chain,\n    };\n\n    SnapshotImporter::import(\n        genesis_db.clone(),\n        genesis_block.clone(),\n        config.snapshot_reader.clone(),\n        watcher,\n    )\n    .await?;\n\n    let genesis_progress_on_chain: Vec<String> = db\n        .on_chain()\n        .iter_all_keys::<GenesisMetadata<OnChain>>(None)\n        .try_collect()?;","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/service/genesis.rs#L70-L106","documentation":"Companion to the on-chain check: the off-chain database's into_genesis() fails when it already contains indexed state. Both databases must be empty for SnapshotImporter to run; this error names the off-chain side as the initialized one.","triggerScenarios":"execute_genesis_block runs while the off-chain DB (balances, tx-index, etc.) at the configured path already holds state from a prior run.","commonSituations":"Same as the on-chain case: reused data directories, partial prior initializations, CI runs sharing paths.","solutions":["Wipe the entire database directory (on-chain AND off-chain together) before re-running genesis.","If state should be preserved, skip genesis import entirely.","Check that db-path isn't shared between nodes/runs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Same emptiness probe must cover BOTH databases — wiping only one side\n// just moves the failure to the other:\nasync fn needs_genesis(db: &CombinedDatabase) -> bool {\n    on_chain_is_empty(db.on_chain()).await && off_chain_is_empty(db.off_chain()).await\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = genesis_result {\n    if e.to_string().contains(\"already initialized\") {\n        return Err(anyhow!(\"off-chain (or on-chain) DB not empty: wipe the whole db-path\"));\n    }\n    return Err(e);\n}","preventionTips":["Wipe on-chain and off-chain databases together — they must be lifecycle-aligned.","Treat 'already initialized' as an idempotency signal: skip, don't fail, on restarts.","Keep db-path ownership 1:1 with chains in orchestration configs."],"tags":["genesis","database","initialization","off-chain"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}