{"record":{"id":"d7b67d9241856ea6","repo":"vitessio/vitess","slug":"findallshardsinkeyspace-cluster-s-keyspace","errorCode":null,"errorMessage":"FindAllShardsInKeyspace(cluster = %s, keyspace = %s) failed: %w","messagePattern":"FindAllShardsInKeyspace\\(cluster = (.+?), keyspace = (.+?)\\) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/cluster.go","lineNumber":632,"sourceCode":"func (c *Cluster) FindAllShardsInKeyspace(ctx context.Context, keyspace string, opts FindAllShardsInKeyspaceOptions) (map[string]*vtctldatapb.Shard, error) {\n\tspan, ctx := trace.NewSpan(ctx, \"Cluster.FindAllShardsInKeyspace\")\n\tdefer span.Finish()\n\n\tAnnotateSpan(c, span)\n\tspan.Annotate(\"keyspace\", keyspace)\n\n\tif !opts.skipPool {\n\t\tif err := c.topoReadPool.Acquire(ctx); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"FindAllShardsInKeyspace(%s) failed to acquire topoReadPool: %w\", keyspace, err)\n\t\t}\n\t\tdefer c.topoReadPool.Release()\n\t}\n\n\tresp, err := c.Vtctld.FindAllShardsInKeyspace(ctx, &vtctldatapb.FindAllShardsInKeyspaceRequest{\n\t\tKeyspace: keyspace,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"FindAllShardsInKeyspace(cluster = %s, keyspace = %s) failed: %w\", c.ID, keyspace, err)\n\t}\n\n\treturn resp.Shards, nil\n}\n\n// FindTablet returns the first tablet in a given cluster that satisfies the filter function.\nfunc (c *Cluster) FindTablet(ctx context.Context, filter func(*vtadminpb.Tablet) bool) (*vtadminpb.Tablet, error) {\n\tspan, ctx := trace.NewSpan(ctx, \"Cluster.FindTablet\")\n\tdefer span.Finish()\n\n\tAnnotateSpan(c, span)\n\n\ttablets, err := c.findTablets(ctx, filter, 1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(tablets) != 1 {","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/cluster.go#L614-L650","documentation":"FindAllShardsInKeyspace delegates the actual topo read to c.Vtctld.FindAllShardsInKeyspace. Any RPC error is wrapped with the cluster ID and keyspace for context. This means the pool was acquired successfully but the vtctld-side lookup failed — e.g. the keyspace does not exist in the topo server, or vtctld/topo connectivity or storage problems.","triggerScenarios":"Calling FindAllShardsInKeyspace for a keyspace that was never created or was already deleted; vtctld unreachable; topo server (etcd/zk) errors; stale cached cluster metadata pointing at the wrong topo.","commonSituations":"Race between a DeleteKeyspace and a concurrent GetWorkflows/GetKeyspace listing; typo'd keyspace name in automation; topo server outage or network partition; vtadmin pointed at a cluster where the keyspace lives under a different cell.","solutions":["Verify the keyspace exists: vtctldclient GetKeyspace <name> before calling","Check vtctld connectivity and health from the vtadmin host","Check topo server (etcd/zookeeper) health and logs for the underlying error","If a concurrent deletion races reads, tolerate/retry on keyspace-not-found","Confirm the vtadmin cluster config points at the correct topo server"],"exampleFix":"// before\nshards, err := cluster.FindAllShardsInKeyspace(ctx, ks, nil) // fails if ks deleted concurrently\n// after\nif _, err := cluster.GetKeyspace(ctx, ks); err != nil {\n    return fmt.Errorf(\"keyspace %s not found, skipping shard lookup: %w\", ks, err)\n}\nshards, err := cluster.FindAllShardsInKeyspace(ctx, ks, nil)","handlingStrategy":"try-catch","validationCode":"_, err := cluster.GetKeyspace(ctx, keyspace)\nif err != nil {\n    return fmt.Errorf(\"keyspace %s does not exist in cluster %s: %w\", keyspace, clusterID, err)\n}","typeGuard":null,"tryCatchPattern":"shards, err := cluster.FindAllShardsInKeyspace(ctx, ks, nil)\nif err != nil {\n    if errors.Is(err, topo.ErrNoNode) || strings.Contains(err.Error(), \"node doesn't exist\") {\n        return nil, fmt.Errorf(\"keyspace %s not found (deleted?)\", ks)\n    }\n    return nil, err\n}","preventionTips":["Confirm keyspace existence before shard lookups in scripts","Check vtctld and topo server health when these errors appear in bursts","Handle races with concurrent DeleteKeyspace by tolerating not-found","Verify vtadmin cluster config points at the right topo server"],"tags":["rpc","topo","keyspace","vtadmin"],"backgroundTag":"rpc-call-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}