{"record":{"id":"e3a45b2fa374e959","repo":"vitessio/vitess","slug":"unable-to-get-shards-for-keyspace-s-error-v","errorCode":null,"errorMessage":"unable to get shards for keyspace: %s, error: %v","messagePattern":"unable to get shards for keyspace: (.+?), error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schemamanager/tablet_executor.go","lineNumber":118,"sourceCode":"\t}\n\texec.uuids = uuids\n\treturn nil\n}\n\n// hasProvidedUUIDs returns true when UUIDs were provided\nfunc (exec *TabletExecutor) hasProvidedUUIDs() bool {\n\treturn len(exec.uuids) != 0\n}\n\n// Open opens a connection to the primary for every shard.\nfunc (exec *TabletExecutor) Open(ctx context.Context, keyspace string) error {\n\tif !exec.isClosed {\n\t\treturn nil\n\t}\n\texec.keyspace = keyspace\n\tshards, err := exec.ts.FindAllShardsInKeyspace(ctx, keyspace, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to get shards for keyspace: %s, error: %v\", keyspace, err)\n\t}\n\texec.tablets = make([]*topodatapb.Tablet, 0, len(shards))\n\tfor shardName, shardInfo := range shards {\n\t\tif !shardInfo.HasPrimary() {\n\t\t\treturn fmt.Errorf(\"shard: %s does not have a primary\", shardName)\n\t\t}\n\t\ttabletInfo, err := exec.ts.GetTablet(ctx, shardInfo.PrimaryAlias)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to get primary tablet info, keyspace: %s, shard: %s, error: %v\", keyspace, shardName, err)\n\t\t}\n\t\texec.tablets = append(exec.tablets, tabletInfo.Tablet)\n\t}\n\n\tif len(exec.tablets) == 0 {\n\t\treturn fmt.Errorf(\"keyspace: %s does not contain any primary tablets\", keyspace)\n\t}\n\texec.isClosed = false\n\treturn nil","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schemamanager/tablet_executor.go#L100-L136","documentation":"TabletExecutor.Open discovers all shards in the target keyspace via the topo server (FindAllShardsInKeyspace) to locate primaries. If the topology lookup fails, this error wraps the underlying topo error, naming the keyspace. The executor cannot proceed without the shard map.","triggerScenarios":"Calling Open when FindAllShardsInKeyspace fails: topo server unreachable, keyspace does not exist, or permission/timeout errors from the topo store.","commonSituations":"Typo in keyspace name; vtctld/vttablet environment with wrong topo flags; etcd/zk outage or network partition; keyspace deleted while a schema change was queued.","solutions":["Check the wrapped error for the topo root cause (not-found vs connection error)","Verify the keyspace exists (vtctldclient GetKeyspaces) and is spelled correctly","Confirm topo server connectivity/flags (etcd/zk endpoints) and retry once the topo is healthy"],"exampleFix":"// before: keyspace typo\nexec.Open(ctx, \"commerc\")\n// after\nexec.Open(ctx, \"commerce\")","handlingStrategy":"try-catch","validationCode":"_, err := ts.FindAllShardsInKeyspace(ctx, keyspace, nil)\nif err != nil { return fmt.Errorf(\"keyspace %q not ready: %w\", keyspace, err) }","typeGuard":null,"tryCatchPattern":"err := exec.Open(ctx, keyspace)\nif err != nil {\n  if strings.Contains(err.Error(), \"unable to get shards for keyspace\") {\n    // check topo health / keyspace existence, then retry with backoff\n  }\n}","preventionTips":["Verify keyspace names with vtctldclient before running schema changes","Monitor topo server (etcd/zk) health","Retry Open with bounded backoff on transient topo errors"],"tags":["schemamanager","topology","keyspace","network"],"backgroundTag":"topology-lookup-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}