{"record":{"id":"ba1fbfb896948a9d","repo":"hyperledger/fabric","slug":"could-not-save-next-block-file-info-to-db-s","errorCode":null,"errorMessage":"Could not save next block file info to db: %s","messagePattern":"Could not save next block file info to db: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"common/ledger/blkstorage/blockfile_mgr.go","lineNumber":120,"sourceCode":"\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 {\n\t\tpanic(fmt.Sprintf(\"Could not open writer to current file: %s\", err))\n\t}\n\terr = currentFileWriter.truncateFile(blockfilesInfo.latestFileSize)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not truncate current file to known size in db: %s\", err))\n\t}\n\tif mgr.index, err = newBlockIndex(indexConfig, indexStore); err != nil {\n\t\tpanic(fmt.Sprintf(\"error in block index: %s\", err))\n\t}\n\n\tmgr.blockfilesInfo = blockfilesInfo\n\tbsi, err := loadBootstrappingSnapshotInfo(rootDir)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockfile_mgr.go#L102-L138","documentation":"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.","triggerScenarios":"leveldb write (batch with sync) fails — disk full, DB corrupted, I/O error, or lock contention — while writing the blockfilesInfo record in newBlockfileMgr.","commonSituations":"Disk full on the ledger volume; corrupted index LevelDB after crash; concurrent peer instance holding the DB lock; read-only filesystem.","solutions":["Free disk space on the ledgersData volume and verify it is writable by the peer user","Ensure no other peer process is using the data dir; remove stale file locks after confirming","If the index DB is corrupted, back it up and delete it so the peer rebuilds it via FS scan"],"exampleFix":"// before: peer fills the disk and panics\n// after: add volume monitoring before start\n// df -h /var/hyperledger/production/ledgersData || exit 1","handlingStrategy":"validation","validationCode":"// ensure the leveldb store is writable and has space before init\ntestFile := filepath.Join(indexPath, \".write-test\")\nif err := os.WriteFile(testFile, []byte(\"1\"), 0o600); err != nil {\n    return fmt.Errorf(\"index store not writable: %w\", err)\n}\nos.Remove(testFile)","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"failed to persist blockfilesInfo: %v\", r)\n    }\n}()","preventionTips":["Alert on disk usage above ~80% on the ledger volume","Confirm no peer duplicates/locks share the data dir","Use read-write mounts only","Restart cleanly after crashes rather than force-killing"],"tags":["leveldb","disk-full","panic"],"backgroundTag":"leveldb-write-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"}