{"record":{"id":"f3038e2522d13cd8","repo":"hyperledger/fabric","slug":"could-not-get-block-file-info-for-current-block-fi","errorCode":null,"errorMessage":"Could not get block file info for current block file from db: %s","messagePattern":"Could not get block file info for current block file from db: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"common/ledger/blkstorage/blockfile_mgr.go","lineNumber":106,"sourceCode":"\t  the file blkstorage\n\t\t\t-- Instantiates a new blockIdxInfo\n\t\t\t-- Loads the index from the db if exists\n\t\t\t-- syncIndex comparing the last block indexed to what is in the FS\n\t\t\t-- If index and file system are not in sync, syncs index from the FS\n\t  *)  Updates blockchain info used by the APIs\n*/\nfunc newBlockfileMgr(id string, conf *Conf, indexConfig *IndexConfig, indexStore *leveldbhelper.DBHandle) (*blockfileMgr, error) {\n\tlogger.Debugf(\"newBlockfileMgr() initializing file-based block storage for ledger: %s \", id)\n\trootDir := conf.getLedgerBlockDir(id)\n\t_, err := fileutil.CreateDirIfMissing(rootDir)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error creating block storage root dir [%s]: %s\", rootDir, err))\n\t}\n\tmgr := &blockfileMgr{rootDir: rootDir, conf: conf, db: indexStore, cache: newCache(defaultBlockCacheSizeBytes)}\n\n\tblockfilesInfo, err := mgr.loadBlkfilesInfo()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not get block file info for current block file from db: %s\", err))\n\t}\n\tif blockfilesInfo == nil {\n\t\tlogger.Info(`Getting block information from block storage`)\n\t\tif blockfilesInfo, err = constructBlockfilesInfo(rootDir); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Could not build blockfilesInfo info from block files: %s\", err))\n\t\t}\n\t\tlogger.Debugf(\"Info constructed by scanning the blocks dir = %s\", spew.Sdump(blockfilesInfo))\n\t} else {\n\t\tlogger.Debug(`Syncing block information from block storage (if needed)`)\n\t\tsyncBlockfilesInfoFromFS(rootDir, blockfilesInfo)\n\t}\n\terr = mgr.saveBlkfilesInfo(blockfilesInfo, true)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not save next block file info to db: %s\", err))\n\t}\n\n\tcurrentFileWriter, err := newBlockfileWriter(deriveBlockfilePath(rootDir, blockfilesInfo.latestFileNumber))\n\tif err != nil {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockfile_mgr.go#L88-L124","documentation":"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.","triggerScenarios":"Error from the leveldb handle while fetching the blockfilesInfo key (LevelDB I/O error, corrupted DB, lock conflicts, disk full) during newBlockfileMgr.","commonSituations":"Corrupted index LevelDB after crash or disk-full event; two peers running against the same data dir; filesystem errors on the ledgerData volume.","solutions":["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","Ensure only one peer process uses the data dir (check for stale processes/locks)","Free disk space and verify filesystem health, then restart the peer"],"exampleFix":"// before: restarting peer with corrupted index\n// after: stop peer, back up and remove index, restart to rescan\n// mv ledgersData/index ledgersData/index.bak && systemctl start peer","handlingStrategy":"validation","validationCode":"// check leveldb dir is accessible and lock is free before init\nif _, err := os.Stat(indexPath); err != nil {\n    return fmt.Errorf(\"index db dir %s missing: %w\", indexPath, err)\n}\nif err := fileutil.FileExists(filepath.Join(indexPath, \"LOCK\")) && anotherPeerRunning() {\n    return fmt.Errorf(\"index db is locked by another process\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        logger.Errorf(\"blockfilesInfo load failed: %v — rebuild index DB\", r)\n    }\n}()","preventionTips":["Run only one peer per data directory","Gracefully stop the peer (SIGTERM) to avoid LevelDB corruption","Monitor free disk space; LevelDB fails on full disks","Back up ledgersData before upgrades"],"tags":["leveldb","corruption","panic"],"backgroundTag":"leveldb-corruption","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"}