dgraph-io/badger · error
Assert failed
Error message
Assert failed
What it means
Assert failed is the fatal message emitted by y.AssertTrue when its boolean condition is false: the process calls log.Fatalf and terminates immediately. It is an internal invariant check, not a recoverable error — firing means Badger reached a state the authors considered impossible (e.g. memtable capacity assumptions in ensureRoomForWrite, flushMemtable or bench harness invariants). The fault is a bug in Badger or memory corruption, not in caller input, so there is no error value to inspect; the program has already died by the time it is observed.
Source
Thrown at y/error.go:43
var debugMode = false
// Check logs fatal if err != nil.
func Check(err error) {
if err != nil {
log.Fatalf("%+v", Wrap(err, ""))
}
}
// Check2 acts as convenience wrapper around Check, using the 2nd argument as error.
func Check2(_ interface{}, err error) {
Check(err)
}
// AssertTrue asserts that b is true. Otherwise, it would log fatal.
func AssertTrue(b bool) {
if !b {
log.Fatalf("%+v", errors.New("Assert failed"))
}
}
// AssertTruef is AssertTrue with extra info.
func AssertTruef(b bool, format string, args ...interface{}) {
if !b {
log.Fatalf("%+v", fmt.Errorf(format, args...))
}
}
// Wrap wraps errors from external lib.
func Wrap(err error, msg string) error {
if !debugMode {
if err == nil {
return nil
}
return fmt.Errorf("%s err: %+v", msg, err)
}View on GitHub (pinned to 2a001d466f)
Solutions
- Capture the fatal log output — it identifies the failing invariant and file/line; report it as a Badger issue with the stack trace and reproduction steps
- Upgrade to the latest badger/v4 patch release, since many assertion bugs are fixed over time
- Check for resource exhaustion (disk full, mmap failures, OOM) and hardware/disk errors that commonly trigger invariant breaks
- Restore from backup into a fresh directory if a specific dataset persistently trips the assertion
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at y/error.go:43 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/62916b8286bb4a90.
Report an issue: GitHub.