{"record":{"id":"568722918a72aa06","repo":"vitessio/vitess","slug":"getkeyspaces-failed-v","errorCode":null,"errorMessage":"GetKeyspaces failed: %v","messagePattern":"GetKeyspaces failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/srv_vschema.go","lineNumber":159,"sourceCode":"\treturn conn.Delete(ctx, nodePath, nil)\n}\n\n// RebuildSrvVSchema rebuilds the SrvVSchema for the provided cell list\n// (or all cells if cell list is empty).\nfunc (ts *Server) RebuildSrvVSchema(ctx context.Context, cells []string) error {\n\t// get the actual list of cells\n\tif len(cells) == 0 {\n\t\tvar err error\n\t\tcells, err = ts.GetKnownCells(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"GetKnownCells failed: %v\", err)\n\t\t}\n\t}\n\n\t// get the keyspaces\n\tkeyspaces, err := ts.GetKeyspaces(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetKeyspaces failed: %v\", err)\n\t}\n\n\t// build the SrvVSchema in parallel, protected by mu\n\twg := sync.WaitGroup{}\n\tmu := sync.Mutex{}\n\tvar finalErr error\n\tsrvVSchema := &vschemapb.SrvVSchema{\n\t\tKeyspaces: map[string]*vschemapb.Keyspace{},\n\t}\n\tfor _, keyspace := range keyspaces {\n\t\twg.Add(1)\n\t\tgo func(keyspace string) {\n\t\t\tdefer wg.Done()\n\n\t\t\tksvs, err := ts.GetVSchema(ctx, keyspace)\n\t\t\tif IsErrType(err, NoNode) {\n\t\t\t\terr = nil\n\t\t\t\tksvs = &KeyspaceVSchemaInfo{","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/srv_vschema.go#L141-L177","documentation":"After determining the cells, RebuildSrvVSchema lists all keyspaces in the topology to build per-keyspace SrvVSchema entries. This error wraps a failure from GetKeyspaces, meaning the global keyspace listing could not be read and the rebuild aborts before writing anything.","triggerScenarios":"Calling RebuildSrvVSchema (directly or via ApplyRoutingRules / InitTabletMap / vschema watcher) when the topo call to list keyspaces fails — topo backend down, context timeout, permission error, or corrupt keyspace directory.","commonSituations":"etcd compaction or session expiry during heavy vtctld activity; transient network blip between vtctld and topo; keyspace deleted concurrently by another process; RBAC/acl misconfiguration on the topo backend.","solutions":["Verify topo health and retry; GetKeyspaces is a read and safe to retry after a transient failure.","Check vtctld logs for the wrapped inner error (e.g. 'context deadline exceeded' vs 'permission denied') and address that root cause.","If a keyspace was deleted concurrently, re-run the rebuild after the delete settles — stale listings cause spurious failures.","Ensure the calling context has a generous timeout; large clusters can exceed short deadlines when listing keyspaces."],"exampleFix":"// before\ncctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)\nerr := ts.RebuildSrvVSchema(cctx, nil) // GetKeyspaces deadline exceeded\n// after\ncctx, cancel := context.WithTimeout(ctx, 30*time.Second)\nerr := ts.RebuildSrvVSchema(cctx, nil)","handlingStrategy":"retry","validationCode":"if _, err := ts.GetKeyspaces(ctx); err != nil {\n    return fmt.Errorf(\"cannot list keyspaces, aborting: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := ts.RebuildSrvVSchema(ctx, cells); err != nil {\n    if strings.Contains(err.Error(), \"GetKeyspaces failed\") && errors.Is(ctx.Err(), nil) {\n        return retryWithBackoff(ctx, func() error { return ts.RebuildSrvVSchema(ctx, cells) })\n    }\n    return err\n}","preventionTips":["Avoid deleting keyspaces concurrently with vschema rebuilds.","Set a generous context timeout for rebuild operations on large clusters.","Alert on topo read latency/errors.","Keep vtctld topo flags consistent with the actual backend endpoints."],"tags":["topo","vschema","keyspaces","connectivity"],"backgroundTag":"topo-unavailable","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}