vitessio/vitess · error

no tablet found to source data in keyspace %s, shard %s

Error message

no tablet found to source data in keyspace %s, shard %s

What it means

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.

Source

Thrown at go/vt/vtctl/workflow/utils.go:691

	}

	var wg sync.WaitGroup
	allErrors := &concurrency.AllErrorRecorder{}
	for _, shard := range shards {
		wg.Add(1)
		go func(cells []string, keyspace string, shard *topo.ShardInfo) {
			defer wg.Done()
			if cells == nil {
				cells = append(cells, shard.PrimaryAlias.Cell)
			}
			tp, err := discovery.NewTabletPicker(ctx, ts.ws.ts, cells, shard.PrimaryAlias.Cell, keyspace, shard.ShardName(), tabletTypesStr, discovery.TabletPickerOptions{})
			if err != nil {
				allErrors.RecordError(err)
				return
			}
			tablets := tp.GetMatchingTablets(ctx)
			if len(tablets) == 0 {
				allErrors.RecordError(fmt.Errorf("no tablet found to source data in keyspace %s, shard %s", keyspace, shard.ShardName()))
				return
			}
		}(cells, keyspace, shard)
	}

	wg.Wait()
	if allErrors.HasErrors() {
		ts.Logger().Error(allErrors.Error())
		return allErrors.Error()
	}
	return nil
}

// LegacyBuildTargets collects MigrationTargets and other metadata (see TargetInfo)
// from a workflow in the target keyspace. It uses VReplicationExec to get the workflow
// details rather than the new TabletManager ReadVReplicationWorkflow RPC. This is
// being used to slowly transition all of the older code, including unit tests, over to
// the new RPC and limit the impact of the new implementation to vtctldclient. You can see

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Run vtctldclient GetTablets (or check vtctld UI) for the failing keyspace/shard and confirm tablets of the requested types exist and are serving.
  2. Widen --tablet-types (e.g. include primary) or --cells so the TabletPicker matches available tablets.
  3. Start/recover the missing tablets in that shard and confirm they appear in the topology with serving state.
  4. If the shard no longer exists meaningfully, correct the shard/cells inputs to the switch-traffic command.

Example fix

// before
vtctldclient MoveTables --workflow sales --target-commerce SwitchTraffic --tablet-types=rdonly // only primary tablets exist
// after
vtctldclient MoveTables --workflow sales --target-commerce SwitchTraffic --tablet-types=primary
Defensive patterns

Strategy: validation

Validate before calling

for _, shard := range shards {
	tablets, err := ts.GetTabletsByShard(ctx, keyspace, shard.ShardName())
	if err != nil || len(tablets) == 0 {
		return fmt.Errorf("precheck: no tablets in %s/%s", keyspace, shard.ShardName())
	}
}

Try / catch

err := areTabletsAvailableToStreamFrom(ctx, req, ts, keyspace, shards)
if err != nil {
	log.Errorf("switch-traffic precheck failed; check serving tablets per shard: %v", err)
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/70245957137359f4. Report an issue: GitHub.