vitessio/vitess · error
vreplication engine is closed
Error message
vreplication engine is closed
What it means
Returned by the vreplication Engine when an operation (wrapped in the wg-tracked run function) is attempted after vre.Open() has not run or after Close() has been called. The engine holds mu and isOpen; any work requiring the engine (e.g. state transitions during shutdown) is rejected while it is closed.
Source
Thrown at go/vt/vttablet/tabletmanager/vreplication/engine.go:789
}
vre.controllers[id] = ct
}
log.Info(fmt.Sprintf("Completed transition for journal:workload %v", je))
}
// WaitForPos waits for the replication to reach the specified position.
func (vre *Engine) WaitForPos(ctx context.Context, id int32, pos string) error {
start := time.Now()
mPos, err := binlogplayer.DecodePosition(pos)
if err != nil {
return err
}
if err := func() error {
vre.mu.Lock()
defer vre.mu.Unlock()
if !vre.isOpen {
return errors.New("vreplication engine is closed")
}
// Ensure that the engine won't be closed while this is running.
vre.wg.Add(1)
return nil
}(); err != nil {
return err
}
defer vre.wg.Done()
if vre.shortcircuit {
return nil
}
dbClient := vre.dbClientFactoryFiltered()
if err := dbClient.Connect(); err != nil {
return err
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Retry after the tablet finishes its shutdown/restart cycle
- Confirm the tablet started with vreplication enabled and check startup logs for engine-open failures
- Serialize admin operations (vdiff, workflow state changes) with tablet restarts so they don't race Close()
- Reopen the engine by restarting vttablet if it was never opened
Example fix
// before // vdiff called while tablet is shutting down -> 'engine is closed' // after // wait for tablet readiness, then retry: vtctldclient Workflow --keyspace ks vdiff sales start // after tablet is up
Defensive patterns
Strategy: retry
Try / catch
if err := engineOp(); errors.Is(err, errClosed) || strings.Contains(err.Error(), "engine is closed") {
// wait for tablet restart, then retry with backoff
time.Sleep(2 * time.Second); retry()
} Prevention
- Don't run vdiff/admin commands during tablet shutdown windows
- Check tablet startup logs for vreplication engine open failures
- Gate automation on tablet health/readiness checks
When it happens
Trigger: Calling engine methods that use the protected run wrapper while the vreplication engine is closed — commonly during or after Close(), or on a tablet where the vreplication engine failed to open at startup.
Common situations: VDiff or vreplication state queries racing with tablet shutdown; engine never opened because startup initialization failed; calling VReplicationExec on a tablet with vreplication disabled.
Related errors
- work queue is not open
- VStreamer is not open
- VStreamer is not open
- BUG: thread with ID: %v must not access closed Throttler
- value out of range
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/be5d6cea202400d4.
Report an issue: GitHub.