hyperledger/fabric · critical

Could not get block file info for current block file from db

Error message

Could not get block file info for current block file from db: %s

What it means

Panic when mgr.loadBlkfilesInfo() fails, i.e. reading the blockfilesInfo checkpoint record from the leveldb index store errors. The manager cannot know where block storage left off, so startup aborts.

Source

Thrown at common/ledger/blkstorage/blockfile_mgr.go:106

	  the file blkstorage
			-- Instantiates a new blockIdxInfo
			-- Loads the index from the db if exists
			-- syncIndex comparing the last block indexed to what is in the FS
			-- If index and file system are not in sync, syncs index from the FS
	  *)  Updates blockchain info used by the APIs
*/
func newBlockfileMgr(id string, conf *Conf, indexConfig *IndexConfig, indexStore *leveldbhelper.DBHandle) (*blockfileMgr, error) {
	logger.Debugf("newBlockfileMgr() initializing file-based block storage for ledger: %s ", id)
	rootDir := conf.getLedgerBlockDir(id)
	_, err := fileutil.CreateDirIfMissing(rootDir)
	if err != nil {
		panic(fmt.Sprintf("Error creating block storage root dir [%s]: %s", rootDir, err))
	}
	mgr := &blockfileMgr{rootDir: rootDir, conf: conf, db: indexStore, cache: newCache(defaultBlockCacheSizeBytes)}

	blockfilesInfo, err := mgr.loadBlkfilesInfo()
	if err != nil {
		panic(fmt.Sprintf("Could not get block file info for current block file from db: %s", err))
	}
	if blockfilesInfo == nil {
		logger.Info(`Getting block information from block storage`)
		if blockfilesInfo, err = constructBlockfilesInfo(rootDir); err != nil {
			panic(fmt.Sprintf("Could not build blockfilesInfo info from block files: %s", err))
		}
		logger.Debugf("Info constructed by scanning the blocks dir = %s", spew.Sdump(blockfilesInfo))
	} else {
		logger.Debug(`Syncing block information from block storage (if needed)`)
		syncBlockfilesInfoFromFS(rootDir, blockfilesInfo)
	}
	err = mgr.saveBlkfilesInfo(blockfilesInfo, true)
	if err != nil {
		panic(fmt.Sprintf("Could not save next block file info to db: %s", err))
	}

	currentFileWriter, err := newBlockfileWriter(deriveBlockfilePath(rootDir, blockfilesInfo.latestFileNumber))
	if err != nil {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Check the LevelDB index dir for corruption; if corruption is confirmed, delete the index DB (ledgersData/fileLockDB / index dirs per docs) and let the peer rebuild via constructBlockfilesInfo
  2. Ensure only one peer process uses the data dir (check for stale processes/locks)
  3. Free disk space and verify filesystem health, then restart the peer

Example fix

// before: restarting peer with corrupted index
// after: stop peer, back up and remove index, restart to rescan
// mv ledgersData/index ledgersData/index.bak && systemctl start peer
Defensive patterns

Strategy: validation

Validate before calling

// check leveldb dir is accessible and lock is free before init
if _, err := os.Stat(indexPath); err != nil {
    return fmt.Errorf("index db dir %s missing: %w", indexPath, err)
}
if err := fileutil.FileExists(filepath.Join(indexPath, "LOCK")) && anotherPeerRunning() {
    return fmt.Errorf("index db is locked by another process")
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        logger.Errorf("blockfilesInfo load failed: %v — rebuild index DB", r)
    }
}()

Prevention

When it happens

Trigger: Error from the leveldb handle while fetching the blockfilesInfo key (LevelDB I/O error, corrupted DB, lock conflicts, disk full) during newBlockfileMgr.

Common situations: Corrupted index LevelDB after crash or disk-full event; two peers running against the same data dir; filesystem errors on the ledgerData volume.

Related errors


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