{"record":{"id":"63636f5bc6f4d02c","repo":"dgraph-io/badger","slug":"errbadchecksum","errorCode":"errBadChecksum","errorMessage":"manifest has checksum mismatch","messagePattern":"manifest has checksum mismatch","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manifest.go","lineNumber":345,"sourceCode":"}\n\nfunc (r *countingReader) Read(p []byte) (n int, err error) {\n\tn, err = r.wrapped.Read(p)\n\tr.count += int64(n)\n\treturn\n}\n\nfunc (r *countingReader) ReadByte() (b byte, err error) {\n\tb, err = r.wrapped.ReadByte()\n\tif err == nil {\n\t\tr.count++\n\t}\n\treturn\n}\n\nvar (\n\terrBadMagic    = errors.New(\"manifest has bad magic\")\n\terrBadChecksum = errors.New(\"manifest has checksum mismatch\")\n)\n\n// ReplayManifestFile reads the manifest file and constructs two manifest objects.  (We need one\n// immutable copy and one mutable copy of the manifest.  Easiest way is to construct two of them.)\n// Also, returns the last offset after a completely read manifest entry -- the file must be\n// truncated at that point before further appends are made (if there is a partial entry after\n// that).  In normal conditions, truncOffset is the file size.\nfunc ReplayManifestFile(fp *os.File, extMagic uint16, opt Options) (Manifest, int64, error) {\n\tr := countingReader{wrapped: bufio.NewReader(fp)}\n\n\tvar magicBuf [8]byte\n\tif _, err := io.ReadFull(&r, magicBuf[:]); err != nil {\n\t\treturn Manifest{}, 0, errBadMagic\n\t}\n\tif !bytes.Equal(magicBuf[0:4], magicText[:]) {\n\t\treturn Manifest{}, 0, errBadMagic\n\t}\n","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/manifest.go#L327-L363","documentation":"errBadChecksum is a sentinel error from ReplayManifestFile raised while replaying MANIFEST change-set blocks: each block's header carries a CRC32C (Castagnoli) checksum over its payload, and the recomputed checksum of the unmarshalled buffer does not match the stored value. This means the MANIFEST content is corrupted mid-file — typically from a partial write, disk fault, or unclean shutdown — not merely a bad header.","triggerScenarios":"Thrown at manifest.go:345 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the MANIFEST file from a known-good backup","Check the disk/filesystem for errors (fsck, SMART) since checksum mismatches often indicate hardware faults","Follow the Badger troubleshooting docs: try dropping a corrupted trailing MANIFEST block so replay stops at the last consistent change set","As a last resort remove the MANIFEST so Badger regenerates it, or drop the database directory and restore from a backup dump"],"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"}