{"record":{"id":"1435d30014a188b0","repo":"vitessio/vitess","slug":"getroutingrules-failed-v","errorCode":null,"errorMessage":"GetRoutingRules failed: %v","messagePattern":"GetRoutingRules failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/srv_vschema.go","lineNumber":200,"sourceCode":"\n\t\t\tmu.Lock()\n\t\t\tdefer mu.Unlock()\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(fmt.Sprintf(\"%v: GetVSchema(%v) failed\", err, keyspace))\n\t\t\t\tfinalErr = err\n\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)","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/srv_vschema.go#L182-L218","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: RoutingRules node absent\nvtctldclient RebuildVSchema -cells zone1 commerce  // GetRoutingRules failed\n// after: seed empty rules first, then rebuild\nvtctldclient ApplyRoutingRules -rules '{\"rules\": []}'\nvtctldclient RebuildVSchema -cells zone1 commerce","handlingStrategy":"validation","validationCode":"if _, err := ts.GetRoutingRules(ctx); err != nil {\n    // seed empty rules before rebuilding\n    ts.SaveRoutingRules(ctx, &vschemapb.RoutingRules{Rules: []*vschemapb.RoutingRule{}})\n}","typeGuard":null,"tryCatchPattern":"if err := ts.RebuildSrvVSchema(ctx, cells); err != nil {\n    if strings.Contains(err.Error(), \"GetRoutingRules failed\") {\n        _ = ts.SaveRoutingRules(ctx, &vschemapb.RoutingRules{})\n        err = ts.RebuildSrvVSchema(ctx, cells)\n    }\n    return err\n}","preventionTips":["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."],"tags":["topo","vschema","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"}