{"record":{"id":"d84be7ae93b9cd1c","repo":"FuelLabs/fuel-core","slug":"on-chain-database-doesn-t-have-height","errorCode":null,"errorMessage":"on-chain database doesn't have height","messagePattern":"on-chain database doesn't have height","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/combined_database.rs","lineNumber":473,"sourceCode":"            )))?;\n\n        Ok(state_config)\n    }\n\n    /// Rollbacks the state of the blockchain to a specific block height.\n    pub fn rollback_to<S>(\n        &mut self,\n        target_block_height: BlockHeight,\n        shutdown_listener: &mut S,\n    ) -> anyhow::Result<()>\n    where\n        S: ShutdownListener,\n    {\n        while !shutdown_listener.is_cancelled() {\n            let on_chain_height = self\n                .on_chain()\n                .latest_height_from_metadata()?\n                .ok_or(anyhow::anyhow!(\"on-chain database doesn't have height\"))?;\n\n            let off_chain_height = self\n                .off_chain()\n                .latest_height_from_metadata()?\n                .ok_or(anyhow::anyhow!(\"off-chain database doesn't have height\"))?;\n\n            let gas_price_chain_height =\n                self.gas_price().latest_height_from_metadata()?;\n            let gas_price_rolled_back = is_equal_or_less_than_or_none(\n                gas_price_chain_height,\n                target_block_height,\n            );\n\n            let compression_db_height =\n                self.compression().latest_height_from_metadata()?;\n            let compression_db_rolled_back =\n                is_equal_or_less_than_or_none(compression_db_height, target_block_height);\n","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/combined_database.rs#L455-L491","documentation":"CombinedDatabase::rollback_to walks the on-chain, off-chain, gas-price and compression databases back to a target block height. It first reads each database's latest height from its metadata column; the on-chain database returning None (no height ever recorded) is fatal because there is nothing to roll back and no baseline to compare against. This means the on-chain database never committed even the genesis block.","triggerScenarios":"Calling rollback_to (startup re-org realignment, --rolling/re-org tooling, snapshot restore flows) on an on-chain database whose metadata column has no height — a freshly created or wiped database.","commonSituations":"Running rollback tooling against a brand-new DB before genesis import; wrong --db-path pointing at an empty directory; metadata column deleted or corrupted; restoring a partial snapshot that omits on-chain metadata.","solutions":["Start the node normally once so genesis (and at least one block) is committed, then retry the rollback.","Verify the database path/configuration points at the intended, initialized chain database.","If metadata is corrupted, restore from a healthy snapshot or re-sync from scratch.","Check disk space and permissions — a failed initial commit can leave the DB without height metadata."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure every component database has a height before rolling back.\nfor name in [\"on-chain\", \"off-chain\"] {\n    let h = match name {\n        \"on-chain\" => combined_db.on_chain().latest_height_from_metadata()?,\n        _ => combined_db.off_chain().latest_height_from_metadata()?,\n    };\n    if h.is_none() {\n        anyhow::bail!(\"{} database is not initialized; import genesis first\", name);\n    }\n}","typeGuard":null,"tryCatchPattern":"match combined_db.rollback_to(target, &mut shutdown) {\n    Ok(()) => Ok(()),\n    Err(e) if e.to_string().contains(\"doesn't have height\") => {\n        // DB empty: initialize by running the node once, then retry\n        initialize_db_then_retry()\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Always run the node until genesis is committed before invoking rollback tooling.","Point rollback tools at the same --db-path the node uses.","Validate snapshots include the metadata columns of every component database."],"tags":["database","rollback","initialization","metadata","rust"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}