{"record":{"id":"e054c495e8bf815c","repo":"FuelLabs/fuel-core","slug":"off-chain-database-doesn-t-have-height","errorCode":null,"errorMessage":"off-chain database doesn't have height","messagePattern":"off-chain database doesn't have height","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/combined_database.rs","lineNumber":478,"sourceCode":"    /// 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\n            #[cfg(feature = \"rpc\")]\n            {\n                let block_aggregation_storage_height = self\n                    .block_aggregation_storage()\n                    .latest_height_from_metadata()?;","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/combined_database.rs#L460-L496","documentation":"Same rollback_to prelude as the on-chain check, but for the off-chain (indexes, GraphQL views) database: off_chain().latest_height_from_metadata() returned None, so the off-chain database has no recorded height and the combined rollback cannot proceed. Rollback is only defined for databases that have processed at least genesis.","triggerScenarios":"rollback_to invoked when the off-chain database is empty or its metadata was never written — typically an off-chain DB created but never synced, or one whose metadata column was wiped while the on-chain DB has data.","commonSituations":"Mixed/partially restored database directories (on-chain restored, off-chain missing); deleting only the off-chain DB files to 'reset indexes' and then running rollback tooling; node crashed during first off-chain commit before metadata flush.","solutions":["Let the node run so the off-chain worker catches up and records a height, then retry the rollback.","If the off-chain DB is disposable, delete it entirely and let the node rebuild it (off-chain data is derivable from on-chain state).","Restore both on-chain and off-chain databases from the same consistent snapshot."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let off_chain = combined_db.off_chain().latest_height_from_metadata()?;\nif off_chain.is_none() {\n    anyhow::bail!(\"off-chain DB not initialized; let the node index genesis first\");\n}\ncombined_db.rollback_to(target, &mut shutdown)?;","typeGuard":null,"tryCatchPattern":"match combined_db.rollback_to(target, &mut shutdown) {\n    Ok(()) => Ok(()),\n    Err(e) if e.to_string().contains(\"off-chain database doesn't have height\") => {\n        // off-chain data is derivable: rebuild it, then retry\n        rebuild_off_chain_db().and_then(|_| combined_db.rollback_to(target, &mut shutdown))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Never delete only part of the off-chain DB; reset it wholesale so it can rebuild.","Restore on-chain and off-chain databases from the same snapshot.","After crashes, let the off-chain worker record a height before running rollbacks."],"tags":["database","rollback","off-chain","initialization","rust"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}