dgraph-io/badger · error

Buffer length: %d greater than file size: %d. Manifest file

Error message

Buffer length: %d greater than file size: %d. Manifest file might be corrupted

What it means

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.

Source

Thrown at manifest.go:401

		return Manifest{}, 0, err
	}

	build := createManifest()
	var offset int64
	for {
		offset = r.count
		var lenCrcBuf [8]byte
		_, err := io.ReadFull(&r, lenCrcBuf[:])
		if err != nil {
			if err == io.EOF || err == io.ErrUnexpectedEOF {
				break
			}
			return Manifest{}, 0, err
		}
		length := y.BytesToU32(lenCrcBuf[0:4])
		// Sanity check to ensure we don't over-allocate memory.
		if length > uint32(stat.Size()) {
			return Manifest{}, 0, fmt.Errorf(
				"Buffer length: %d greater than file size: %d. Manifest file might be corrupted",
				length, stat.Size())
		}
		var buf = make([]byte, length)
		if _, err := io.ReadFull(&r, buf); err != nil {
			if err == io.EOF || err == io.ErrUnexpectedEOF {
				break
			}
			return Manifest{}, 0, err
		}
		if crc32.Checksum(buf, y.CastagnoliCrcTable) != y.BytesToU32(lenCrcBuf[4:8]) {
			return Manifest{}, 0, errBadChecksum
		}

		var changeSet pb.ManifestChangeSet
		if err := proto.Unmarshal(buf, &changeSet); err != nil {
			return Manifest{}, 0, err
		}

View on GitHub (pinned to 2a001d466f)

Solutions

  1. Restore the MANIFEST from a backup copy
  2. Run filesystem/disk checks — an impossible length field usually implies corruption from a bad disk or unclean shutdown
  3. Truncate the MANIFEST at the last valid block boundary (see Badger troubleshooting docs) so replay uses only the intact prefix
  4. If unrecoverable, recreate the database directory and reload data from an external backup/export
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at manifest.go:401 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/09ad1c4e83da555e. Report an issue: GitHub.