{"record":{"id":"5ce4eba75a7cce04","repo":"vitessio/vitess","slug":"getkeyspaceroutingrules-failed-v","errorCode":null,"errorMessage":"GetKeyspaceRoutingRules failed: %v","messagePattern":"GetKeyspaceRoutingRules failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/srv_vschema.go","lineNumber":212,"sourceCode":"\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)\n\t\tgo func(cell string) {\n\t\t\tdefer wg.Done()\n\t\t\tif err := ts.UpdateSrvVSchema(ctx, cell, srvVSchema); err != nil {\n\t\t\t\tlog.Error(fmt.Sprintf(\"%v: UpdateSrvVSchema(%v) failed\", err, cell))\n\t\t\t\tmu.Lock()\n\t\t\t\tfinalErr = err","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/srv_vschema.go#L194-L230","documentation":"During RebuildSrvVSchema, keyspace-level routing rules are fetched with GetKeyspaceRoutingRules and folded into the published SrvVSchema. This error is thrown when that topo read fails, aborting the rebuild.","triggerScenarios":"Calling RebuildSrvVSchema (or callers like ApplyRoutingRules / InitRoutingRules) when the KeyspaceRoutingRules object cannot be read from the topo store — missing node, decode error, or backend failure.","commonSituations":"KeyspaceRoutingRules topo node deleted by hand or by a faulty script; interrupted apply left partial state; topo backend connectivity loss; RBAC misconfiguration preventing reads on that key.","solutions":["Write a valid empty record via `vtctldclient ApplyKeyspaceRoutingRules -rules '{\"rules\": []}'` (or reapply intended rules), then rebuild.","Inspect the KeyspaceRoutingRules topo node and restore/recreate it if missing or malformed.","Resolve the underlying topo error (connectivity, permissions) surfaced in the wrapped cause from the logs.","Retry the rebuild; the operation is idempotent and safe to re-run once the topo read succeeds."],"exampleFix":"// before: missing KeyspaceRoutingRules node\nvtctldclient RebuildVSchema commerce  // GetKeyspaceRoutingRules failed\n// after\nvtctldclient ApplyKeyspaceRoutingRules -rules '{\"rules\": []}'\nvtctldclient RebuildVSchema commerce","handlingStrategy":"validation","validationCode":"if _, err := ts.GetKeyspaceRoutingRules(ctx); err != nil {\n    ts.SaveKeyspaceRoutingRules(ctx, &vschemapb.KeyspaceRoutingRules{Rules: []*vschemapb.KeyspaceRoutingRule{}})\n}","typeGuard":null,"tryCatchPattern":"err := ts.RebuildSrvVSchema(ctx, cells)\nif err != nil && strings.Contains(err.Error(), \"GetKeyspaceRoutingRules failed\") {\n    if reErr := ts.SaveKeyspaceRoutingRules(ctx, &vschemapb.KeyspaceRoutingRules{}); reErr == nil {\n        err = ts.RebuildSrvVSchema(ctx, cells)\n    }\n}\nreturn err","preventionTips":["Create keyspace routing rules via ApplyKeyspaceRoutingRules, never by editing topo nodes directly.","Back up all routing-rule topo nodes as part of cluster config.","Avoid concurrent rule applies and vschema rebuilds.","Check topo RBAC grants for the vtctld service account."],"tags":["topo","vschema","keyspace-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"}