dgraph-io/badger · error

errBadChecksum

errBadChecksum

Error message

manifest has checksum mismatch

What it means

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.

Source

Thrown at manifest.go:345

}

func (r *countingReader) Read(p []byte) (n int, err error) {
	n, err = r.wrapped.Read(p)
	r.count += int64(n)
	return
}

func (r *countingReader) ReadByte() (b byte, err error) {
	b, err = r.wrapped.ReadByte()
	if err == nil {
		r.count++
	}
	return
}

var (
	errBadMagic    = errors.New("manifest has bad magic")
	errBadChecksum = errors.New("manifest has checksum mismatch")
)

// ReplayManifestFile reads the manifest file and constructs two manifest objects.  (We need one
// immutable copy and one mutable copy of the manifest.  Easiest way is to construct two of them.)
// Also, returns the last offset after a completely read manifest entry -- the file must be
// truncated at that point before further appends are made (if there is a partial entry after
// that).  In normal conditions, truncOffset is the file size.
func ReplayManifestFile(fp *os.File, extMagic uint16, opt Options) (Manifest, int64, error) {
	r := countingReader{wrapped: bufio.NewReader(fp)}

	var magicBuf [8]byte
	if _, err := io.ReadFull(&r, magicBuf[:]); err != nil {
		return Manifest{}, 0, errBadMagic
	}
	if !bytes.Equal(magicBuf[0:4], magicText[:]) {
		return Manifest{}, 0, errBadMagic
	}

View on GitHub (pinned to 2a001d466f)

Solutions

  1. Restore the MANIFEST file from a known-good backup
  2. Check the disk/filesystem for errors (fsck, SMART) since checksum mismatches often indicate hardware faults
  3. Follow the Badger troubleshooting docs: try dropping a corrupted trailing MANIFEST block so replay stops at the last consistent change set
  4. As a last resort remove the MANIFEST so Badger regenerates it, or drop the database directory and restore from a backup dump
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at manifest.go:345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dgraph-io/badger@2a001d466f (2026-09-05). Data as JSON: /api/errors/63636f5bc6f4d02c. Report an issue: GitHub.