vitessio/vitess · error
GetRoutingRules failed: %v
Error message
GetRoutingRules failed: %v
What it means
RebuildSrvVSchema embeds the current routing rules into the rebuilt SrvVSchema. This error is thrown when reading the RoutingRules object from the topo via GetRoutingRules fails, aborting the rebuild just before it saves the SrvVSchema to the cells.
Source
Thrown at go/vt/topo/srv_vschema.go:200
mu.Lock()
defer mu.Unlock()
if err != nil {
log.Error(fmt.Sprintf("%v: GetVSchema(%v) failed", err, keyspace))
finalErr = err
return
}
srvVSchema.Keyspaces[keyspace] = ksvs.Keyspace
}(keyspace)
}
wg.Wait()
if finalErr != nil {
return finalErr
}
rr, err := ts.GetRoutingRules(ctx)
if err != nil {
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)View on GitHub (pinned to 01a25a7d17)
Solutions
- Re-create the routing rules object: run `vtctldclient ApplyRoutingRules -rules '{}'` to write a valid (empty) RoutingRules record, then retry the rebuild.
- Inspect the topo node holding RoutingRules (e.g. etcdctl get /vt/routing_rules) and restore it if it was deleted or corrupted.
- Fix topo backend connectivity/permissions based on the wrapped inner error in the logs.
- Upgrade paths: if migrating across Vitess versions, ensure all topo nodes were migrated, not just keyspaces.
Example fix
// before: RoutingRules node absent
vtctldclient RebuildVSchema -cells zone1 commerce // GetRoutingRules failed
// after: seed empty rules first, then rebuild
vtctldclient ApplyRoutingRules -rules '{"rules": []}'
vtctldclient RebuildVSchema -cells zone1 commerce Defensive patterns
Strategy: validation
Validate before calling
if _, err := ts.GetRoutingRules(ctx); err != nil {
// seed empty rules before rebuilding
ts.SaveRoutingRules(ctx, &vschemapb.RoutingRules{Rules: []*vschemapb.RoutingRule{}})
} Try / catch
if err := ts.RebuildSrvVSchema(ctx, cells); err != nil {
if strings.Contains(err.Error(), "GetRoutingRules failed") {
_ = ts.SaveRoutingRules(ctx, &vschemapb.RoutingRules{})
err = ts.RebuildSrvVSchema(ctx, cells)
}
return err
} Prevention
- Never delete topo nodes like routing_rules by hand; use ApplyRoutingRules with empty rules instead.
- Include all topo node types in backup/restore procedures.
- Serialize routing-rule updates and vschema rebuilds.
- Alert on topo write/read failures.
When it happens
Trigger: Calling RebuildSrvVSchema (or ApplyRoutingRules / InitRoutingRules) when the routing rules object is missing/unreadable in the topo — the underlying Get call returned an error rather than an empty ruleset.
Common situations: RoutingRules node manually deleted from etcd/zk; partial topo restore from backup where some nodes were skipped; permission errors on the routing rules key; topo backend flakiness during a routing-rules update by another process.
Related errors
- SrvVSchema has no entry for keyspace %v
- GetRoutingRules: %w
- GetKnownCells failed: %v
- GetKeyspaces failed: %v
- GetShardRoutingRules failed: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/1435d30014a188b0.
Report an issue: GitHub.