{"record":{"id":"580b60c6e2230b02","repo":"hyperledger/fabric","slug":"error-during-commit-to-history-db","errorCode":null,"errorMessage":"Error during commit to history db","messagePattern":"Error during commit to history db","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/ledger/kvledger/kv_ledger.go","lineNumber":719,"sourceCode":"\tif err = l.commitToPvtAndBlockStore(pvtdataAndBlock, purgeMarkers); err != nil {\n\t\treturn err\n\t}\n\telapsedBlockstorageAndPvtdataCommit := time.Since(startBlockstorageAndPvtdataCommit)\n\n\tstartCommitState := time.Now()\n\tl.txmgr.UpdateBatchWithAppInitiatedPvtKeysToPurge(pvtKeysToDelete)\n\tlogger.Debugf(\"[%s] Committing block [%d] transactions to state database\", l.ledgerID, blockNo)\n\tif err = l.txmgr.Commit(); err != nil {\n\t\tpanic(errors.WithMessage(err, \"error during commit to txmgr\"))\n\t}\n\telapsedCommitState := time.Since(startCommitState)\n\n\t// History database could be written in parallel with state and/or async as a future optimization,\n\t// although it has not been a bottleneck...no need to clutter the log with elapsed duration.\n\tif l.historyDB != nil {\n\t\tlogger.Debugf(\"[%s] Committing block [%d] transactions to history database\", l.ledgerID, blockNo)\n\t\tif err := l.historyDB.Commit(block); err != nil {\n\t\t\tpanic(errors.WithMessage(err, \"Error during commit to history db\"))\n\t\t}\n\t}\n\n\tlogger.Infof(\n\t\t\"[%s] Committed block [%d] with %d transaction(s) in %dms (state_validation=%dms block_and_pvtdata_commit=%dms state_commit=%dms)\"+\n\t\t\t\" commitHash=[%x]\",\n\t\tl.ledgerID, block.Header.Number, len(block.Data.Data),\n\t\ttime.Since(startBlockProcessing)/time.Millisecond,\n\t\telapsedBlockProcessing/time.Millisecond,\n\t\telapsedBlockstorageAndPvtdataCommit/time.Millisecond,\n\t\telapsedCommitState/time.Millisecond,\n\t\tl.commitHash,\n\t)\n\n\tl.updateBlockStats(\n\t\telapsedBlockProcessing,\n\t\telapsedBlockstorageAndPvtdataCommit,\n\t\telapsedCommitState,","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/kv_ledger.go#L701-L737","documentation":"kvLedger.commit panics with this wrapped error when historyDB.Commit(block) fails after the state DB commit succeeded. The history write failure is escalated to a panic since the peer cannot safely continue committing with an inconsistent history index. The underlying cause is preserved in the wrapped error.","triggerScenarios":"During block commit when ledger.history.enableHistoryDatabase=true and the history LevelDB write fails: disk full, I/O error, corrupted history DB, or the history DB directory was removed while the peer ran.","commonSituations":"Disk exhaustion, history DB corruption, partial/manual cleanup of ledgersData/history while peer is running, or permission changes on the data directory.","solutions":["Inspect the wrapped cause in the peer log (usually disk or I/O)","Free disk space / fix permissions for ledgersData/history","Stop the peer and drop the history DB (rm -rf ledgersData/history); it rebuilds on restart","If history is not needed, set ledger.history.enableHistoryDatabase=false in core.yaml"],"exampleFix":"// before: panic: Error during commit to history db: ...\n// after (operational):\n//   # stop peer, then:\n//   rm -rf /var/hyperledger/production/ledgersData/history\n//   # restart peer (history rebuilds from block store)","handlingStrategy":"retry","validationCode":"// If history is enabled, ensure the history dir exists and is writable before start\nif enableHistoryDatabase && !isWritable(historyDBDir) {\n    return errors.New(\"history DB dir not writable\")\n}","typeGuard":null,"tryCatchPattern":"func safeCommit(b *common.Block) (err error) {\n    defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"history commit panic: %v\", r) } }()\n    ledger.Commit(b)\n    return nil\n}\n// recovery: stop peer, rm -rf ledgersData/history, restart (history rebuilds)","preventionTips":["Monitor disk usage on the ledger volume","Do not delete DB directories while the peer is running","Disable history DB (ledger.history.enableHistoryDatabase=false) if unused"],"tags":["hyperledger-fabric","ledger","commit","history-database","panic"],"backgroundTag":"history-db-commit-failed","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"}