{"record":{"id":"09ad1c4e83da555e","repo":"dgraph-io/badger","slug":"buffer-length-d-greater-than-file-size-d-mani","errorCode":null,"errorMessage":"Buffer length: %d greater than file size: %d. Manifest file might be corrupted","messagePattern":"Buffer length: (.+?) greater than file size: (.+?)\\. Manifest file might be corrupted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manifest.go","lineNumber":401,"sourceCode":"\t\treturn Manifest{}, 0, err\n\t}\n\n\tbuild := createManifest()\n\tvar offset int64\n\tfor {\n\t\toffset = r.count\n\t\tvar lenCrcBuf [8]byte\n\t\t_, err := io.ReadFull(&r, lenCrcBuf[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF || err == io.ErrUnexpectedEOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn Manifest{}, 0, err\n\t\t}\n\t\tlength := y.BytesToU32(lenCrcBuf[0:4])\n\t\t// Sanity check to ensure we don't over-allocate memory.\n\t\tif length > uint32(stat.Size()) {\n\t\t\treturn Manifest{}, 0, fmt.Errorf(\n\t\t\t\t\"Buffer length: %d greater than file size: %d. Manifest file might be corrupted\",\n\t\t\t\tlength, stat.Size())\n\t\t}\n\t\tvar buf = make([]byte, length)\n\t\tif _, err := io.ReadFull(&r, buf); err != nil {\n\t\t\tif err == io.EOF || err == io.ErrUnexpectedEOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn Manifest{}, 0, err\n\t\t}\n\t\tif crc32.Checksum(buf, y.CastagnoliCrcTable) != y.BytesToU32(lenCrcBuf[4:8]) {\n\t\t\treturn Manifest{}, 0, errBadChecksum\n\t\t}\n\n\t\tvar changeSet pb.ManifestChangeSet\n\t\tif err := proto.Unmarshal(buf, &changeSet); err != nil {\n\t\t\treturn Manifest{}, 0, err\n\t\t}","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/manifest.go#L383-L419","documentation":"Raised in ReplayManifestFile as a sanity check before allocating a buffer: a MANIFEST change-set block header declares a payload length larger than the entire MANIFEST file size. A well-formed block can never exceed the file, so this indicates the length field is garbage — the file is corrupted (bit rot, partial write, wrong file) — and the check prevents a huge make([]byte, length) allocation/OOM. The two printed values are the declared block length and the actual file size.","triggerScenarios":"Thrown at manifest.go:401 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the MANIFEST from a backup copy","Run filesystem/disk checks — an impossible length field usually implies corruption from a bad disk or unclean shutdown","Truncate the MANIFEST at the last valid block boundary (see Badger troubleshooting docs) so replay uses only the intact prefix","If unrecoverable, recreate the database directory and reload data from an external backup/export"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}