dgraph-io/badger · error
Throttle Do Done mismatch
Error message
Throttle Do Done mismatch
What it means
This is a panic raised inside Throttle.Done (y/y.go) when the internal channel is empty at Done time. Throttle pairs each Do() call with exactly one Done(); the select-with-default detects that Done was invoked more times than outstanding Do calls — an API-misuse bug in the worker goroutine (extra Done, or Done called outside the throttle's lifecycle). Since it is a panic, not an error return, it crashes the goroutine and typically the process; there is no recovery path inside Badger.
Source
Thrown at y/y.go:229
return nil
case err := <-t.errCh:
if err != nil {
return err
}
}
}
}
// Done should be called by workers when they finish working. They can also
// pass the error status of work done.
func (t *Throttle) Done(err error) {
if err != nil {
t.errCh <- err
}
select {
case <-t.ch:
default:
panic("Throttle Do Done mismatch")
}
t.wg.Done()
}
// Finish waits until all workers have finished working. It would return any error passed by Done.
// If Finish is called multiple time, it will wait for workers to finish only once(first time).
// From next calls, it will return same error as found on first call.
func (t *Throttle) Finish() error {
t.once.Do(func() {
t.wg.Wait()
close(t.ch)
close(t.errCh)
for err := range t.errCh {
if err != nil {
t.finishErr = err
return
}
}View on GitHub (pinned to 2a001d466f)
Solutions
- Audit the code calling Throttle.Done: every call site must correspond to exactly one successful Throttle.Do on the same instance
- Ensure error paths do not call Done twice (e.g. once in the worker and once in a deferred cleanup)
- Wrap critical goroutines with recover if third-party code misuses the throttle, and log the stack to find the extra Done
- Add unit tests that pair Do/Done under error conditions to prevent regression
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at y/y.go:229 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/87a428aa8933f25e.
Report an issue: GitHub.