hyperledger/fabric · critical

Error during commit to history db

Error message

Error during commit to history db

What it means

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.

Source

Thrown at core/ledger/kvledger/kv_ledger.go:719

	if err = l.commitToPvtAndBlockStore(pvtdataAndBlock, purgeMarkers); err != nil {
		return err
	}
	elapsedBlockstorageAndPvtdataCommit := time.Since(startBlockstorageAndPvtdataCommit)

	startCommitState := time.Now()
	l.txmgr.UpdateBatchWithAppInitiatedPvtKeysToPurge(pvtKeysToDelete)
	logger.Debugf("[%s] Committing block [%d] transactions to state database", l.ledgerID, blockNo)
	if err = l.txmgr.Commit(); err != nil {
		panic(errors.WithMessage(err, "error during commit to txmgr"))
	}
	elapsedCommitState := time.Since(startCommitState)

	// History database could be written in parallel with state and/or async as a future optimization,
	// although it has not been a bottleneck...no need to clutter the log with elapsed duration.
	if l.historyDB != nil {
		logger.Debugf("[%s] Committing block [%d] transactions to history database", l.ledgerID, blockNo)
		if err := l.historyDB.Commit(block); err != nil {
			panic(errors.WithMessage(err, "Error during commit to history db"))
		}
	}

	logger.Infof(
		"[%s] Committed block [%d] with %d transaction(s) in %dms (state_validation=%dms block_and_pvtdata_commit=%dms state_commit=%dms)"+
			" commitHash=[%x]",
		l.ledgerID, block.Header.Number, len(block.Data.Data),
		time.Since(startBlockProcessing)/time.Millisecond,
		elapsedBlockProcessing/time.Millisecond,
		elapsedBlockstorageAndPvtdataCommit/time.Millisecond,
		elapsedCommitState/time.Millisecond,
		l.commitHash,
	)

	l.updateBlockStats(
		elapsedBlockProcessing,
		elapsedBlockstorageAndPvtdataCommit,
		elapsedCommitState,

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Inspect the wrapped cause in the peer log (usually disk or I/O)
  2. Free disk space / fix permissions for ledgersData/history
  3. Stop the peer and drop the history DB (rm -rf ledgersData/history); it rebuilds on restart
  4. If history is not needed, set ledger.history.enableHistoryDatabase=false in core.yaml

Example fix

// before: panic: Error during commit to history db: ...
// after (operational):
//   # stop peer, then:
//   rm -rf /var/hyperledger/production/ledgersData/history
//   # restart peer (history rebuilds from block store)
Defensive patterns

Strategy: retry

Validate before calling

// If history is enabled, ensure the history dir exists and is writable before start
if enableHistoryDatabase && !isWritable(historyDBDir) {
    return errors.New("history DB dir not writable")
}

Try / catch

func safeCommit(b *common.Block) (err error) {
    defer func() { if r := recover(); r != nil { err = fmt.Errorf("history commit panic: %v", r) } }()
    ledger.Commit(b)
    return nil
}
// recovery: stop peer, rm -rf ledgersData/history, restart (history rebuilds)

Prevention

When it happens

Trigger: 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.

Common situations: Disk exhaustion, history DB corruption, partial/manual cleanup of ledgersData/history while peer is running, or permission changes on the data directory.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/580b60c6e2230b02. Report an issue: GitHub.