vitessio/vitess · error

no target shards specified for workflow %s

Error message

no target shards specified for workflow %s 

What it means

Returned by the materializer when creating a workflow with no target shards specified; the workflow's target keyspace must resolve to at least one shard.

Source

Thrown at go/vt/wrangler/materializer.go:1102

	if len(sourceShards) == 0 {
		return nil, fmt.Errorf("no source shards specified for workflow %s ", ms.Workflow)
	}

	targetShards, err := wr.ts.GetServingShards(ctx, ms.TargetKeyspace)
	if err != nil {
		return nil, err
	}
	if len(ms.SourceShards) > 0 {
		var targetShards2 []*topo.ShardInfo
		for _, shard := range targetShards {
			if slices.Contains(ms.SourceShards, shard.ShardName()) {
				targetShards2 = append(targetShards2, shard)
			}
		}
		targetShards = targetShards2
	}
	if len(targetShards) == 0 {
		return nil, fmt.Errorf("no target shards specified for workflow %s ", ms.Workflow)
	}

	sourceTs := wr.ts
	if ms.ExternalCluster != "" { // when the source is an external mysql cluster mounted using the Mount command
		externalTopo, err := wr.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)
		if err != nil {
			return nil, fmt.Errorf("failed to open external topo: %v", err)
		}
		sourceTs = externalTopo
	}
	differentPVs := false
	sourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)
	if err != nil {
		return nil, fmt.Errorf("failed to get source keyspace vschema: %v", err)
	}
	differentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)

	return &materializer{

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Ensure the target keyspace exists and its shards are created and serving (ListShards on the target).
  2. Fix the TargetShards names or omit the option to use all target shards.
  3. Verify the target keyspace name is correct.

Example fix

// before: target keyspace not yet created
vtctldclient Reshard --sourceks commerce ... --targetks custoemr
// after: create keyspace/shards first, then Reshard with correct keyspace
Defensive patterns

Strategy: validation

Validate before calling

shards, _ := wr.ts.GetShardNames(ctx, targetKeyspace)
if len(shards) == 0 {
  return fmt.Errorf("target keyspace %s has no shards", targetKeyspace)
}
for _, want := range requestedTargetShards {
  if !slices.Contains(shards, want) {
    return fmt.Errorf("target shard %s not found", want)
  }
}

Prevention

When it happens

Trigger: prepareMaterializerStreams with ms.TargetShards yielding zero shards — specified shard names matching nothing in the target keyspace, or the target keyspace has no serving shards.

Common situations: Reshard/MoveTables invoked before the target keyspace was created or its shards added; misspelled shard names in --target-shards; wrong target keyspace name.

Related errors


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