{"record":{"id":"6c53a6cca141fc2b","repo":"vitessio/vitess","slug":"no-shards-found-in-keyspace","errorCode":null,"errorMessage":"no shards found in keyspace","messagePattern":"no shards found in keyspace","errorType":"error_code","errorClass":"ErrNoShardsForKeyspace","httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/vexec/vexec.go","lineNumber":57,"sourceCode":"\t// VExecTableQualifier is the qualifier that all tables supported by vexec\n\t// are prefixed by.\n\tVExecTableQualifier = \"_vt\"\n\n\t// VReplicationLogTableName is the unqualified name of the vreplication_log\n\t// table supported by vexec.\n\tVReplicationLogTableName = \"vreplication_log\"\n\t// VReplicationTableName is the unqualified name of the vreplication table\n\t// supported by vexec.\n\tVReplicationTableName = \"vreplication\"\n)\n\nvar ( // Topo lookup errors.\n\t// ErrNoShardPrimary occurs when a shard is found with no serving\n\t// primary.\n\tErrNoShardPrimary = errors.New(\"no primary found for shard\")\n\t// ErrNoShardsForKeyspace occurs when attempting to run a vexec on an empty\n\t// keyspace.\n\tErrNoShardsForKeyspace = errors.New(\"no shards found in keyspace\")\n)\n\nvar ( // Query parsing and planning errors.\n\t// ErrUnsupportedQuery occurs when attempting to run an unsupported query\n\t// through vexec.\n\tErrUnsupportedQuery = errors.New(\"query not supported by vexec\")\n\t// ErrUnsupportedTable occurs when attempting to run vexec on an unsupported\n\t// table. At the time of writing, this occurs when attempting to query any\n\t// table other than _vt.vreplication.\n\tErrUnsupportedTable = errors.New(\"table not supported by vexec\")\n)\n\n// VExec provides the main interface to planning and executing vexec queries\n// (normally, queries on tables in the `_vt` database). It currently supports\n// some limited vreplication queries; this set of supported behavior will expand\n// over time. It may be extended to support schema_migrations queries as well.\ntype VExec struct {\n\tts  *topo.Server","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/vexec/vexec.go#L39-L75","documentation":"ErrNoShardsForKeyspace is thrown by the vexec package when a vexec command is run against a keyspace that contains zero shards. vexec plans and executes queries (currently only against _vt.vreplication) across all shards of a keyspace, so with no shards there is nothing to fan out to and planning cannot proceed. It is a sentinel error (errors.New) so callers can compare with errors.Is.","triggerScenarios":"Calling vexec (e.g. PlanQuery or the vtctld VExec handlers) against a keyspace whose shard list, fetched from the topology via ts.GetShardNames, is empty.","commonSituations":"Typo in the keyspace name passed to a vexec command; keyspace exists but all shards have been removed; topology (etcd/zk) is partially wiped; running vexec before a keyspace has been created or shards added.","solutions":["Verify the keyspace name is spelled correctly and exists (vtctldclient GetKeyspaces).","List shards with vtctldclient GetShards <keyspace> to confirm the keyspace actually has shards.","If the keyspace is intentionally empty, do not run vexec against it; create the needed shards/tablets first.","Check the topology service is healthy and you are pointed at the right global topo cells."],"exampleFix":"// before\nvexec.Run(ctx, ts, \"UPDATE _vt.vreplication SET state='Running'\", \"wrong_keyspace\")\n// after\nshards, _ := ts.GetShardNames(ctx, \"commerce\")\nif len(shards) == 0 { return fmt.Errorf(\"keyspace commerce has no shards\") }\nvexec.Run(ctx, ts, \"UPDATE _vt.vreplication SET state='Running'\", \"commerce\")","handlingStrategy":"validation","validationCode":"shards, err := ts.GetShardNames(ctx, keyspace)\nif err != nil { return err }\nif len(shards) == 0 {\n    return fmt.Errorf(\"keyspace %s has no shards; cannot run vexec\", keyspace)\n}","typeGuard":null,"tryCatchPattern":"if err := vexec.Run(...); err != nil {\n    if errors.Is(err, vexec.ErrNoShardsForKeyspace) {\n        // keyspace empty: skip or fail with clear message\n    }\n    return err\n}","preventionTips":["Validate the keyspace exists and has shards before invoking vexec.","Use vtctldclient GetShards as a pre-check in scripts.","Double-check keyspace spelling; avoid hardcoding keyspaces in config."],"tags":["topology","keyspace","vexec","vtctld"],"backgroundTag":"empty-keyspace-no-shards","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}