dgraph-io/badger · info
errFillTables
errFillTables
Error message
Unable to fill tables
What it means
errFillTables is a sentinel error returned by doCompact when it cannot pick tables for a compaction — meaning there may be enough tables queued but a def could not be built (e.g. target level busy or no candidates). Badger treats it as benign: callers explicitly ignore it and do not report it to end users.
Source
Thrown at levels.go:1601
if cd.thisLevel.level != 0 && len(newTables) > 2*s.kv.opt.LevelSizeMultiplier {
s.kv.opt.Infof("This Range (numTables: %d)\nLeft:\n%s\nRight:\n%s\n",
len(cd.top), hex.Dump(cd.thisRange.left), hex.Dump(cd.thisRange.right))
s.kv.opt.Infof("Next Range (numTables: %d)\nLeft:\n%s\nRight:\n%s\n",
len(cd.bot), hex.Dump(cd.nextRange.left), hex.Dump(cd.nextRange.right))
}
return nil
}
func tablesToString(tables []*table.Table) []string {
var res []string
for _, t := range tables {
res = append(res, fmt.Sprintf("%05d", t.ID()))
}
res = append(res, ".")
return res
}
var errFillTables = errors.New("Unable to fill tables")
// doCompact picks some table on level l and compacts it away to the next level.
func (s *levelsController) doCompact(id int, p compactionPriority) error {
l := p.level
y.AssertTrue(l < s.kv.opt.MaxLevels) // Sanity check.
if p.t.baseLevel == 0 {
p.t = s.levelTargets()
}
_, span := otel.Tracer("").Start(context.TODO(), "Badger.Compaction")
defer span.End()
cd := compactDef{
compactorId: id,
p: p,
t: p.t,
thisLevel: s.levels[l],
dropPrefixes: p.dropPrefixes,View on GitHub (pinned to 2a001d466f)
Solutions
- Nothing needed — this is expected flow control; do not log it as an error
- If compactions never progress, check level sizes/badger info output and options (NumLevelZeroTables, baseLevelSize)
- Match on the sentinel with errors.Is if you drive compaction manually
Example fix
// before
if err := db.lc.doCompact(173, p); err != nil {
return err // wrongly surfaces benign errFillTables
}
// after
if err := db.lc.doCompact(173, p); err != nil {
if errors.Is(err, errFillTables) {
return nil // benign: nothing to compact right now
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: treat errFillTables as success when driving compactions manually
if err := db.lc.doCompact(id, p); errors.Is(err, errFillTables) { /* nothing to do */ } Try / catch
// Go
switch err := db.lc.doCompact(id, p); {
case err == nil:
// compacted
case errors.Is(err, errFillTables):
// benign: no tables could be filled; do not report to users
default:
log.Printf("compaction failed: %v", err)
} Prevention
- Always special-case errFillTables as benign (mirroring badger's own callers at db.go:635 and levels.go:516)
- Do not alert/retry aggressively on this sentinel
- If it repeats constantly, inspect level sizes and compaction options
- Use errors.Is rather than string comparison for the sentinel
When it happens
Trigger: doCompact runs (automatically or induced, e.g. db.go:635's level:0/score:1.73 trigger) and runCompactDef/fillTables returns without building a compaction def; also observed via close() path per the declaration.
Common situations: Normal operation when compaction candidates are transiently unavailable; heavy write load delaying compaction; induced test compactions that find nothing to do.
Related errors
- ErrNoRewrite
- Cannot have 1 compactor. Need at least 2
- error during flatten in StreamWriter: %w
- Base level can't be zero.
- Filesizes cannot be zero. Targets are not set
AI-assisted analysis of dgraph-io/badger@2a001d466f (2026-09-05).
Data as JSON: /api/errors/58349a0ac0585016.
Report an issue: GitHub.