{"record":{"id":"70245957137359f4","repo":"vitessio/vitess","slug":"no-tablet-found-to-source-data-in-keyspace-s-sha","errorCode":null,"errorMessage":"no tablet found to source data in keyspace %s, shard %s","messagePattern":"no tablet found to source data in keyspace (.+?), shard (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/utils.go","lineNumber":691,"sourceCode":"\t}\n\n\tvar wg sync.WaitGroup\n\tallErrors := &concurrency.AllErrorRecorder{}\n\tfor _, shard := range shards {\n\t\twg.Add(1)\n\t\tgo func(cells []string, keyspace string, shard *topo.ShardInfo) {\n\t\t\tdefer wg.Done()\n\t\t\tif cells == nil {\n\t\t\t\tcells = append(cells, shard.PrimaryAlias.Cell)\n\t\t\t}\n\t\t\ttp, err := discovery.NewTabletPicker(ctx, ts.ws.ts, cells, shard.PrimaryAlias.Cell, keyspace, shard.ShardName(), tabletTypesStr, discovery.TabletPickerOptions{})\n\t\t\tif err != nil {\n\t\t\t\tallErrors.RecordError(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttablets := tp.GetMatchingTablets(ctx)\n\t\t\tif len(tablets) == 0 {\n\t\t\t\tallErrors.RecordError(fmt.Errorf(\"no tablet found to source data in keyspace %s, shard %s\", keyspace, shard.ShardName()))\n\t\t\t\treturn\n\t\t\t}\n\t\t}(cells, keyspace, shard)\n\t}\n\n\twg.Wait()\n\tif allErrors.HasErrors() {\n\t\tts.Logger().Error(allErrors.Error())\n\t\treturn allErrors.Error()\n\t}\n\treturn nil\n}\n\n// LegacyBuildTargets collects MigrationTargets and other metadata (see TargetInfo)\n// from a workflow in the target keyspace. It uses VReplicationExec to get the workflow\n// details rather than the new TabletManager ReadVReplicationWorkflow RPC. This is\n// being used to slowly transition all of the older code, including unit tests, over to\n// the new RPC and limit the impact of the new implementation to vtctldclient. You can see","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/utils.go#L673-L709","documentation":"areTabletsAvailableToStreamFrom pre-checks that, before switching traffic, at least one serving tablet matching the workflow's tablet types exists in every shard of the source keyspace. For each shard it spawns a TabletPicker; if the picker returns zero tablets for a shard, this error is recorded. It means traffic cannot safely be switched because there is no tablet in that shard to source data from.","triggerScenarios":"Calling WorkflowSwitchTraffic when a shard has no tablets of the requested types (e.g. only PRIMARY present but tablet_types=replica,rdonly), tablets are not serving in the specified cells, the keyspace/shard name is wrong, or all matching tablets are down/decommissioned.","commonSituations":"Replica tablets in a cell are down for maintenance; a shard was resharded away and has no tablets left; cells option points at a cell with no tablets for that keyspace; tablet_types filter excludes the only available tablets (e.g. excluding PRIMARY in a single-tablet cluster).","solutions":["Run vtctldclient GetTablets (or check vtctld UI) for the failing keyspace/shard and confirm tablets of the requested types exist and are serving.","Widen --tablet-types (e.g. include primary) or --cells so the TabletPicker matches available tablets.","Start/recover the missing tablets in that shard and confirm they appear in the topology with serving state.","If the shard no longer exists meaningfully, correct the shard/cells inputs to the switch-traffic command."],"exampleFix":"// before\nvtctldclient MoveTables --workflow sales --target-commerce SwitchTraffic --tablet-types=rdonly // only primary tablets exist\n// after\nvtctldclient MoveTables --workflow sales --target-commerce SwitchTraffic --tablet-types=primary","handlingStrategy":"validation","validationCode":"for _, shard := range shards {\n\ttablets, err := ts.GetTabletsByShard(ctx, keyspace, shard.ShardName())\n\tif err != nil || len(tablets) == 0 {\n\t\treturn fmt.Errorf(\"precheck: no tablets in %s/%s\", keyspace, shard.ShardName())\n\t}\n}","typeGuard":null,"tryCatchPattern":"err := areTabletsAvailableToStreamFrom(ctx, req, ts, keyspace, shards)\nif err != nil {\n\tlog.Errorf(\"switch-traffic precheck failed; check serving tablets per shard: %v\", err)\n\treturn err\n}","preventionTips":["Before SwitchTraffic, run vtctldclient GetTablets and confirm every shard has serving tablets of the requested types","Keep --tablet-types consistent with what actually runs in the cells (don't filter to replica-only if only primaries exist)","Monitor tablet liveness; fix down replicas before running workflow switches"],"tags":["topology","tablet-discovery","vreplication","workflow"],"backgroundTag":"no-serving-tablet","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}