vitessio/vitess · error
GetShardRoutingRules failed: %v
Error message
GetShardRoutingRules failed: %v
What it means
RebuildSrvVSchema also embeds shard routing rules into the SrvVSchema it publishes. This error wraps a failure from GetShardRoutingRules reading the ShardRoutingRules topo object, aborting the rebuild before saving to cells.
Source
Thrown at go/vt/topo/srv_vschema.go:206
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)
}
srvVSchema.MirrorRules = mr
// now save the SrvVSchema in all cells in parallel
for _, cell := range cells {
wg.Add(1)View on GitHub (pinned to 01a25a7d17)
Solutions
- Re-seed the rules with `vtctldclient ApplyShardRoutingRules -rules '{"rules": []}'`, then retry the rebuild.
- Read the ShardRoutingRules topo node directly (etcdctl/zkCli) and repair or delete+recreate it if corrupted.
- Check the wrapped inner error: permission problems need topo RBAC fixes; timeouts need topo/network fixes.
- If a concurrent ApplyShardRoutingRules is in flight, serialize the operations — run the rebuild after the apply completes.
Example fix
// before: corrupted ShardRoutingRules
vtctldclient RebuildVSchema commerce // GetShardRoutingRules failed
// after
vtctldclient ApplyShardRoutingRules -rules '{"rules": []}'
vtctldclient RebuildVSchema commerce Defensive patterns
Strategy: validation
Validate before calling
if _, err := ts.GetShardRoutingRules(ctx); err != nil {
ts.SaveShardRoutingRules(ctx, &vschemapb.ShardRoutingRules{Rules: []*vschemapb.ShardRoutingRule{}})
} Try / catch
err := ts.RebuildSrvVSchema(ctx, cells)
if err != nil && strings.Contains(err.Error(), "GetShardRoutingRules failed") {
if reErr := ts.SaveShardRoutingRules(ctx, &vschemapb.ShardRoutingRules{}); reErr == nil {
err = ts.RebuildSrvVSchema(ctx, cells)
}
}
return err Prevention
- Apply shard routing rules only via vtctldclient ApplyShardRoutingRules.
- Don't interrupt ApplyShardRoutingRules mid-write.
- Restore all vschema-related topo nodes when migrating or restoring a topo.
- Upgrade vtctld in lockstep with topo format changes.
When it happens
Trigger: Calling RebuildSrvVSchema or ApplyShardRoutingRules when the ShardRoutingRules record cannot be read from the topo — node missing, corrupted protobuf, permission denied, or transient topo error.
Common situations: ShardRoutingRules node removed during a manual topo cleanup; interrupted ApplyShardRoutingRules left a truncated record; topo backend outage; version skew where an older vtctld cannot parse newer rule formats.
Related errors
- SrvVSchema has no entry for keyspace %v
- GetKnownCells failed: %v
- GetKeyspaces failed: %v
- GetRoutingRules failed: %v
- GetKeyspaceRoutingRules failed: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/d5592991f0f9f574.
Report an issue: GitHub.