{"record":{"id":"d5592991f0f9f574","repo":"vitessio/vitess","slug":"getshardroutingrules-failed-v","errorCode":null,"errorMessage":"GetShardRoutingRules failed: %v","messagePattern":"GetShardRoutingRules failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/srv_vschema.go","lineNumber":206,"sourceCode":"\t\t\t\treturn\n\t\t\t}\n\t\t\tsrvVSchema.Keyspaces[keyspace] = ksvs.Keyspace\n\t\t}(keyspace)\n\t}\n\twg.Wait()\n\tif finalErr != nil {\n\t\treturn finalErr\n\t}\n\n\trr, err := ts.GetRoutingRules(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetRoutingRules failed: %v\", err)\n\t}\n\tsrvVSchema.RoutingRules = rr\n\n\tsrr, err := ts.GetShardRoutingRules(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetShardRoutingRules failed: %v\", err)\n\t}\n\tsrvVSchema.ShardRoutingRules = srr\n\n\tkrr, err := ts.GetKeyspaceRoutingRules(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetKeyspaceRoutingRules failed: %v\", err)\n\t}\n\tsrvVSchema.KeyspaceRoutingRules = krr\n\n\tmr, err := ts.GetMirrorRules(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetMirrorRules failed: %v\", err)\n\t}\n\tsrvVSchema.MirrorRules = mr\n\n\t// now save the SrvVSchema in all cells in parallel\n\tfor _, cell := range cells {\n\t\twg.Add(1)","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/srv_vschema.go#L188-L224","documentation":"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.","triggerScenarios":"Calling RebuildSrvVSchema or ApplyShardRoutingRules when the ShardRoutingRules record cannot be read from the topo — node missing, corrupted protobuf, permission denied, or transient topo error.","commonSituations":"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.","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."],"exampleFix":"// before: corrupted ShardRoutingRules\nvtctldclient RebuildVSchema commerce   // GetShardRoutingRules failed\n// after\nvtctldclient ApplyShardRoutingRules -rules '{\"rules\": []}'\nvtctldclient RebuildVSchema commerce","handlingStrategy":"validation","validationCode":"if _, err := ts.GetShardRoutingRules(ctx); err != nil {\n    ts.SaveShardRoutingRules(ctx, &vschemapb.ShardRoutingRules{Rules: []*vschemapb.ShardRoutingRule{}})\n}","typeGuard":null,"tryCatchPattern":"err := ts.RebuildSrvVSchema(ctx, cells)\nif err != nil && strings.Contains(err.Error(), \"GetShardRoutingRules failed\") {\n    if reErr := ts.SaveShardRoutingRules(ctx, &vschemapb.ShardRoutingRules{}); reErr == nil {\n        err = ts.RebuildSrvVSchema(ctx, cells)\n    }\n}\nreturn err","preventionTips":["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."],"tags":["topo","vschema","shard-routing-rules"],"backgroundTag":"topo-object-missing","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}