hyperledger/fabric · critical

Could not save next block file info to db: %s

Error message

Could not save next block file info to db: %s

What it means

Panic when saveBlkfilesInfo fails to persist the (possibly synced) blockfilesInfo checkpoint to the leveldb index store during manager initialization. Storage cannot record its checkpoint, so startup is aborted.

Source

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

	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 {
		panic(fmt.Sprintf("Could not open writer to current file: %s", err))
	}
	err = currentFileWriter.truncateFile(blockfilesInfo.latestFileSize)
	if err != nil {
		panic(fmt.Sprintf("Could not truncate current file to known size in db: %s", err))
	}
	if mgr.index, err = newBlockIndex(indexConfig, indexStore); err != nil {
		panic(fmt.Sprintf("error in block index: %s", err))
	}

	mgr.blockfilesInfo = blockfilesInfo
	bsi, err := loadBootstrappingSnapshotInfo(rootDir)
	if err != nil {
		return nil, err

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Free disk space on the ledgersData volume and verify it is writable by the peer user
  2. Ensure no other peer process is using the data dir; remove stale file locks after confirming
  3. If the index DB is corrupted, back it up and delete it so the peer rebuilds it via FS scan

Example fix

// before: peer fills the disk and panics
// after: add volume monitoring before start
// df -h /var/hyperledger/production/ledgersData || exit 1
Defensive patterns

Strategy: validation

Validate before calling

// ensure the leveldb store is writable and has space before init
testFile := filepath.Join(indexPath, ".write-test")
if err := os.WriteFile(testFile, []byte("1"), 0o600); err != nil {
    return fmt.Errorf("index store not writable: %w", err)
}
os.Remove(testFile)

Try / catch

defer func() {
    if r := recover(); r != nil {
        err = fmt.Errorf("failed to persist blockfilesInfo: %v", r)
    }
}()

Prevention

When it happens

Trigger: leveldb write (batch with sync) fails — disk full, DB corrupted, I/O error, or lock contention — while writing the blockfilesInfo record in newBlockfileMgr.

Common situations: Disk full on the ledger volume; corrupted index LevelDB after crash; concurrent peer instance holding the DB lock; read-only filesystem.

Related errors


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