vitessio/vitess · error

GetMirrorRules failed: %v

Error message

GetMirrorRules failed: %v

What it means

RebuildSrvVSchema also merges mirror rules into the SrvVSchema. This error wraps a failure from GetMirrorRules reading the MirrorRules object from the topo, aborting the rebuild before the per-cell save step.

Source

Thrown at go/vt/topo/srv_vschema.go:218

		return fmt.Errorf("GetRoutingRules failed: %v", err)
	}
	srvVSchema.RoutingRules = rr

	srr, err := ts.GetShardRoutingRules(ctx)
	if err != nil {
		return fmt.Errorf("GetShardRoutingRules failed: %v", err)
	}
	srvVSchema.ShardRoutingRules = srr

	krr, err := ts.GetKeyspaceRoutingRules(ctx)
	if err != nil {
		return fmt.Errorf("GetKeyspaceRoutingRules failed: %v", err)
	}
	srvVSchema.KeyspaceRoutingRules = krr

	mr, err := ts.GetMirrorRules(ctx)
	if err != nil {
		return fmt.Errorf("GetMirrorRules failed: %v", err)
	}
	srvVSchema.MirrorRules = mr

	// now save the SrvVSchema in all cells in parallel
	for _, cell := range cells {
		wg.Add(1)
		go func(cell string) {
			defer wg.Done()
			if err := ts.UpdateSrvVSchema(ctx, cell, srvVSchema); err != nil {
				log.Error(fmt.Sprintf("%v: UpdateSrvVSchema(%v) failed", err, cell))
				mu.Lock()
				finalErr = err
				mu.Unlock()
			}
		}(cell)
	}
	wg.Wait()

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Reinitialize the rules with `vtctldclient ApplyMirrorRules -rules '{"rules": []}'`, then retry the rebuild.
  2. Inspect the MirrorRules topo node directly and recreate it if deleted or corrupted.
  3. Fix the underlying topo issue (connectivity/auth) indicated by the wrapped inner error.
  4. If running an older Vitess binary against a newer topo layout, upgrade vtctld so it can read the MirrorRules node type.

Example fix

// before: MirrorRules node absent after topo restore
vtctldclient RebuildVSchema commerce  // GetMirrorRules failed
// after
vtctldclient ApplyMirrorRules -rules '{"rules": []}'
vtctldclient RebuildVSchema commerce
Defensive patterns

Strategy: validation

Validate before calling

if _, err := ts.GetMirrorRules(ctx); err != nil {
    ts.SaveMirrorRules(ctx, &vschemapb.MirrorRules{Rules: []*vschemapb.MirrorRule{}})
}

Try / catch

err := ts.RebuildSrvVSchema(ctx, cells)
if err != nil && strings.Contains(err.Error(), "GetMirrorRules failed") {
    if reErr := ts.SaveMirrorRules(ctx, &vschemapb.MirrorRules{}); reErr == nil {
        err = ts.RebuildSrvVSchema(ctx, cells)
    }
}
return err

Prevention

When it happens

Trigger: Calling RebuildSrvVSchema (or its callers: ApplyRoutingRules, InitMirrorRules, vschema watcher) when the MirrorRules topo object cannot be read — node absent, protobuf decode failure, or topo backend error.

Common situations: MirrorRules node never initialized or manually removed; topo restore skipped newer node types introduced in later Vitess versions; transient etcd/zk errors; permissions on the mirror rules key.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/3a15fe45f51ce5d8. Report an issue: GitHub.