{"record":{"id":"c4bbe0dd14b1999c","repo":"vitessio/vitess","slug":"failed-to-get-shard-s-s-v","errorCode":null,"errorMessage":"failed to get shard %s/%s: %v","messagePattern":"failed to get shard (.+?)/(.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/clone.go","lineNumber":86,"sourceCode":"\tutils.SetFlagBoolVar(fs, &cloneFromPrimary, \"clone-from-primary\", cloneFromPrimary, \"Clone data from the primary tablet in the shard using MySQL CLONE REMOTE instead of restoring from backup. Requires MySQL 8.0.17+. Mutually exclusive with --clone-from-tablet.\")\n\tutils.SetFlagStringVar(fs, &cloneFromTablet, \"clone-from-tablet\", cloneFromTablet, \"Clone data from this tablet using MySQL CLONE REMOTE instead of restoring from backup (tablet alias, e.g., zone1-123). Requires MySQL 8.0.17+. Mutually exclusive with --clone-from-primary.\")\n\tutils.SetFlagDurationVar(fs, &cloneRestartWaitTimeout, \"clone-restart-wait-timeout\", cloneRestartWaitTimeout, \"Timeout for waiting for MySQL to restart after CLONE REMOTE.\")\n}\n\n// CloneFromDonor clones data from the specified donor tablet using MySQL CLONE REMOTE and returns the GTID position of the cloned data. If mycnf is non-nil, CloneFromDonor may use it to restart mysqld locally when CLONE completes but MySQL cannot restart itself.\nfunc CloneFromDonor(ctx context.Context, topoServer *topo.Server, mysqld MysqlDaemon, mycnf *Mycnf, keyspace, shard string) (replication.Position, error) {\n\tvar donorAlias *topodatapb.TabletAlias\n\tvar err error\n\n\tswitch {\n\tcase cloneFromPrimary && cloneFromTablet != \"\":\n\t\treturn replication.Position{}, errors.New(\"--clone-from-primary and --clone-from-tablet are mutually exclusive\")\n\tcase cloneFromPrimary:\n\t\t// Look up the primary tablet from topology.\n\t\tlog.Info(fmt.Sprintf(\"Looking up primary tablet for shard %s/%s for use as CLONE REMOTE donor\", keyspace, shard))\n\t\tsi, err := topoServer.GetShard(ctx, keyspace, shard)\n\t\tif err != nil {\n\t\t\treturn replication.Position{}, fmt.Errorf(\"failed to get shard %s/%s: %v\", keyspace, shard, err)\n\t\t}\n\t\tif topoproto.TabletAliasIsZero(si.PrimaryAlias) {\n\t\t\treturn replication.Position{}, fmt.Errorf(\"shard %s/%s has no primary\", keyspace, shard)\n\t\t}\n\t\tdonorAlias = si.PrimaryAlias\n\t\tlog.Info(fmt.Sprintf(\"Found primary tablet %s for use as CLONE REMOTE donor\", topoproto.TabletAliasString(donorAlias)))\n\tcase cloneFromTablet != \"\":\n\t\t// Parse the explicit donor tablet alias.\n\t\tlog.Info(fmt.Sprintf(\"Using tablet %s for use as CLONE REMOTE donor\", cloneFromTablet))\n\t\tdonorAlias, err = topoproto.ParseTabletAlias(cloneFromTablet)\n\t\tif err != nil {\n\t\t\treturn replication.Position{}, fmt.Errorf(\"invalid tablet alias %q: %v\", cloneFromTablet, err)\n\t\t}\n\tdefault:\n\t\treturn replication.Position{}, errors.New(\"no donor specified\")\n\t}\n\n\t// Get donor tablet info from topology.","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/clone.go#L68-L104","documentation":"CloneFromDonor wraps a topo.GetShard failure when resolving the primary of the target shard for a CLONE-based restore. The shard record could not be read from the topology server, so the donor tablet alias cannot be determined.","triggerScenarios":"Calling CloneFromDonor (or restoreFromCloneLocked) with --clone-from-primary where the topology connection fails, the shard does not exist, or the topo backend is unreachable.","commonSituations":"Typo in keyspace/shard name, vtctld/topo (etcd/zk) outage, shard never created, running against the wrong topo server (wrong flags/env).","solutions":["Verify keyspace/shard names with `vtctldclient GetShard <keyspace>/<shard>`.","Check topology server connectivity and flags (topo implementation, server address).","Create the shard if it doesn't exist (`vtctldclient CreateKeyspace`/`CreateShard`).","Retry after topo server recovers if it was a transient outage."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check\nif _, err := vtctldclientExecute(\"GetShard\", keyspace+\"/\"+shard); err != nil {\n\t// abort before starting restore\n}","typeGuard":null,"tryCatchPattern":"pos, err := mysqlctl.CloneFromDonor(ctx, ...)\nif err != nil && strings.Contains(err.Error(), \"failed to get shard\") {\n\t// check topo connectivity / shard existence before retry\n}","preventionTips":["Verify keyspace/shard names with vtctldclient before restore","Monitor topo server health","Use consistent topo flags across tooling"],"tags":["topology","clone","shard"],"backgroundTag":"topo-shard-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}