vitessio/vitess · error
target shard %v has no primary tablet
Error message
target shard %v has no primary tablet
What it means
buildResharder requires every target shard to have a primary tablet (PrimaryAlias set) so the vreplication streams have somewhere to replicate into. If a target shard has no elected primary, this error names the shard and aborts ReshardCreate.
Source
Thrown at go/vt/vtctl/workflow/resharder.go:112
return nil, vterrors.Wrapf(err, "GetShard(%s) failed", shard)
}
if !si.IsPrimaryServing {
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")
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Initialize the shard's primary: `vtctl InitShardPrimary <keyspace>/<shard> <tablet-alias>` (or force flag as appropriate)
- Verify with `vtctl GetShard <keyspace>/<shard>` that PrimaryAlias is now set before re-running Reshard
- Bring up/repair the missing target tablet so it can be promoted
Example fix
// before (shard 40- has no primary) Reshard --source-shards=0- --target-shards=0-40,40- // after vtctl InitShardPrimary ks/40- zone1-0000000100 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.PrimaryAlias == nil {
return fmt.Errorf("pre-check: target shard %s has no primary; run InitShardPrimary", shard)
}
} Try / catch
if _, err := reshardCreate(ctx, req); err != nil {
if strings.Contains(err.Error(), "has no primary tablet") {
// init the shard primary, then retry ReshardCreate
}
return err
} Prevention
- Always run InitShardPrimary on every new target shard before Reshard
- Verify PrimaryAlias via GetShard in the reshard pre-flight
- Bring up all target tablets and confirm election before starting the workflow
When it happens
Trigger: ReshardCreate targets new shards whose primaries were not initialized — e.g. target tablets registered but InitShardPrimary never run on one of the new shards.
Common situations: New shards created for the split but one target tablet failed to start before Reshard; forgotten InitShardPrimary on a fresh shard; target tablet in a bad state so no primary was elected.
Related errors
- source shard %v is not in serving state
- target shard %v is in serving state
- VReplication stream has the same workflow name as the reshar
- VReplication stream has the same workflow name as the reshar
- no primary tablet found for materialization workflow %s and
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/d5e140c0e3f81f04.
Report an issue: GitHub.