vitessio/vitess · error
target shard %v is in serving state
Error message
target shard %v is in serving state
What it means
For resharding, target shards must be writable-only receivers: their primary must NOT be serving. If a target shard's primary is already serving, streams could receive conflicting writes, so buildResharder rejects it with this error naming the shard.
Source
Thrown at go/vt/vtctl/workflow/resharder.go:115
return nil, fmt.Errorf("source shard %v is not in serving state", shard)
}
rs.sourceShards = append(rs.sourceShards, si)
primary, err := s.ts.GetTablet(ctx, si.PrimaryAlias)
if err != nil {
return nil, vterrors.Wrapf(err, "GetTablet(%s) failed", si.PrimaryAlias)
}
rs.sourcePrimaries[si.ShardName()] = primary
}
for _, shard := range targets {
si, err := s.ts.GetShard(ctx, keyspace, shard)
if err != nil {
return nil, vterrors.Wrapf(err, "GetShard(%s) failed", shard)
}
if si.PrimaryAlias == nil {
return nil, fmt.Errorf("target shard %v has no primary tablet", shard)
}
if si.IsPrimaryServing {
return nil, fmt.Errorf("target shard %v is in serving state", shard)
}
rs.targetShards = append(rs.targetShards, si)
primary, err := s.ts.GetTablet(ctx, si.PrimaryAlias)
if err != nil {
return nil, vterrors.Wrapf(err, "GetTablet(%s) failed", si.PrimaryAlias)
}
rs.targetPrimaries[si.ShardName()] = primary
}
if err := topotools.ValidateForReshard(rs.sourceShards, rs.targetShards); err != nil {
return nil, vterrors.Wrap(err, "ValidateForReshard")
}
if err := rs.validateTargets(ctx); err != nil {
return nil, vterrors.Wrap(err, "validateTargets")
}
vschema, err := s.ts.GetVSchema(ctx, keyspace)
if err != nil {
return nil, vterrors.Wrap(err, "GetVSchema")View on GitHub (pinned to 01a25a7d17)
Solutions
- Remove serving state from the target shards (`vtctl SetShardIsPrimaryServing <keyspace>/<shard> false` or TabletReserveForReshard flow)
- Choose correct, non-serving target shards for the reshard
- If a previous reshard completed, do not reuse its target shards; create new empty target shards
Example fix
// before (shard 40- already serving) Reshard --source-shards=0- --target-shards=0-40,40- // after vtctl SetShardIsPrimaryServing ks/40- false Reshard --source-shards=0- --target-shards=0-40,40-
Defensive patterns
Strategy: validation
Validate before calling
for _, shard := range targetShards {
si, err := ts.GetShard(ctx, ks, shard)
if err != nil { return err }
if si.IsPrimaryServing {
return fmt.Errorf("pre-check: target shard %s is serving; unset serving before Reshard", shard)
}
} Try / catch
if _, err := reshardCreate(ctx, req); err != nil {
if strings.Contains(err.Error(), "is in serving state") {
// disable serving on target shards or pick fresh targets, then retry
}
return err
} Prevention
- Never reuse serving shards as reshard targets; create fresh empty targets
- Check IsPrimaryServing on targets in the pre-flight script
- Follow the documented reserve-for-reshard flow to prepare target shards
When it happens
Trigger: ReshardCreate is called while a designated target shard has IsPrimaryServing=true — e.g. re-running a Reshard whose target shards were previously serving, or accidentally targeting shards of an already-serving keyspace.
Common situations: Retrying a completed/aborted reshard without cleaning up; resharding from a snapshot where target shards were pre-serving; serving state not cleared after a previous workflow was cancelled.
Related errors
- source shard %v is not in serving state
- target shard %v has no primary tablet
- VReplication stream has the same workflow name as the reshar
- VReplication stream has the same workflow name as the reshar
- both atomic copy and partial mode cannot be specified for th
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/36482bdb72502e94.
Report an issue: GitHub.