{"record":{"id":"90b95de8a2b0db07","repo":"hyperledger/fabric","slug":"the-s-database-height-d-is-ahead-of-the-block","errorCode":null,"errorMessage":"the %s database [height=%d] is ahead of the block store [height=%d]. This is possible when the %s database is not dropped after a ledger reset/rollback. The %s database can safely be dropped and will be rebuilt up to block store height upon the next peer start","messagePattern":"the (.+?) database \\[height=(.+?)\\] is ahead of the block store \\[height=(.+?)\\]\\. This is possible when the (.+?) database is not dropped after a ledger reset/rollback\\. The (.+?) database can safely be dropped and will be rebuilt up to block store height upon the next peer start","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/ledger/kvledger/kv_ledger.go","lineNumber":411,"sourceCode":"\t\t\treturn err\n\t\t}\n\n\t\tif l.bootSnapshotMetadata != nil {\n\t\t\tlastBlockInSnapshot := l.bootSnapshotMetadata.LastBlockNumber\n\t\t\tif nextRequiredBlock <= lastBlockInSnapshot {\n\t\t\t\treturn errors.Errorf(\n\t\t\t\t\t\"recovery for DB [%s] not possible. Ledger [%s] is created from a snapshot. Last block in snapshot = [%d], DB needs block [%d] onward\",\n\t\t\t\t\trecoverable.Name(),\n\t\t\t\t\tl.ledgerID,\n\t\t\t\t\tlastBlockInSnapshot,\n\t\t\t\t\tnextRequiredBlock,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tif nextRequiredBlock > lastBlockInBlockStore+1 {\n\t\t\tdbName := recoverable.Name()\n\t\t\treturn fmt.Errorf(\"the %s database [height=%d] is ahead of the block store [height=%d]. \"+\n\t\t\t\t\"This is possible when the %s database is not dropped after a ledger reset/rollback. \"+\n\t\t\t\t\"The %s database can safely be dropped and will be rebuilt up to block store height upon the next peer start\",\n\t\t\t\tdbName, nextRequiredBlock, lastBlockInBlockStore+1, dbName, dbName)\n\t\t}\n\t\tif recoverFlag {\n\t\t\trecoverers = append(recoverers, &recoverer{nextRequiredBlock, recoverable})\n\t\t}\n\t}\n\tif len(recoverers) == 0 {\n\t\treturn nil\n\t}\n\tif len(recoverers) == 1 {\n\t\treturn l.recommitLostBlocks(recoverers[0].nextRequiredBlock, lastBlockInBlockStore, recoverers[0].recoverable)\n\t}\n\n\t// both dbs need to be recovered\n\tif recoverers[0].nextRequiredBlock > recoverers[1].nextRequiredBlock {\n\t\t// swap (put the lagger db at 0 index)","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/kv_ledger.go#L393-L429","documentation":"syncStateAndHistoryDBWithBlockstore returns this when a recoverable database's height is ahead of the block store height (nextRequiredBlock > lastBlockInBlockStore+1). This means the DB contains more blocks than the block store, which only happens when the DB was not dropped during a reset/rollback. Fabric requires the DB to be dropped; it will be rebuilt to block-store height at next start.","triggerScenarios":"peer node rollback/reset applied to the block store without removing the state or history DB; the DB height exceeds blockstore height+1 when the ledger is opened by recoverDBs.","commonSituations":"Operator ran peer node rollback but a DB directory under ledgersData was skipped (wrong path, permission issue); manual blockstore replacement while keeping old DBs; mixed restore of blockstore from backup without matching DBs.","solutions":["Drop the offending database directory (state or history under ledgersData) and restart the peer","Re-run peer node reset/rollback with correct ledgersData paths so all DBs are reset together","Restore a fully consistent backup of blockstore plus all DBs from the same point in time"],"exampleFix":"// before: rolled back blockstore but state DB still ahead\n// after:\n//   peer node rollback --channel myc --blockNumber 1000   # use built-in rollback which drops DBs\n// or manually: rm -rf /var/hyperledger/production/ledgersData/state  # then restart peer","handlingStrategy":"validation","validationCode":"// Before rollback/reset, stop the peer and use the built-in command which handles DBs:\n// peer node rollback --channel <c> --blockNumber <n>\n// (it drops state/history/bookkeeper so their heights match the block store)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use peer node reset/rollback instead of manually editing blockstore dirs","Stop the peer before any ledger data manipulation","After any manual data restore, verify blockstore height >= DB heights"],"tags":["hyperledger-fabric","ledger","rollback","state-database"],"backgroundTag":"database-height-ahead-of-blockstore","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}