vitessio/vitess · error
primary-elect tablet %v is not in the shard
Error message
primary-elect tablet %v is not in the shard
What it means
PlannedReparentShard validates that the requested PrimaryElectTabletAlias exists in the shard's tablet map before reparenting. If the alias is not found among the shard's tablets, the reparent is aborted — the RPC failed validation and no topology change was made.
Source
Thrown at go/vt/vtctl/grpcvtctldserver/server.go:2869
return err
}
log.Info(fmt.Sprintf("Getting a new durability policy for %v", durabilityName))
durability, err := policy.GetDurabilityPolicy(durabilityName)
if err != nil {
return err
}
event.DispatchUpdate(ev, "reading tablet map")
tabletMap, err := s.ts.GetTabletMapForShard(ctx, req.Keyspace, req.Shard)
if err != nil {
return err
}
// Check the primary elect is in tabletMap.
primaryElectTabletAliasStr := topoproto.TabletAliasString(req.PrimaryElectTabletAlias)
primaryElectTabletInfo, ok := tabletMap[primaryElectTabletAliasStr]
if !ok {
return fmt.Errorf("primary-elect tablet %v is not in the shard", topoproto.TabletAliasString(req.PrimaryElectTabletAlias))
}
ev.NewPrimary = primaryElectTabletInfo.CloneVT()
// Check the primary is the only primary is the shard, or -force was used.
_, primaryTabletMap := topotools.SortedTabletMap(tabletMap)
if !topoproto.TabletAliasEqual(shardInfo.PrimaryAlias, req.PrimaryElectTabletAlias) {
if !req.Force {
return fmt.Errorf("primary-elect tablet %v is not the shard primary, use -force to proceed anyway", topoproto.TabletAliasString(req.PrimaryElectTabletAlias))
}
logger.Warningf("primary-elect tablet %v is not the shard primary, proceeding anyway as -force was used", topoproto.TabletAliasString(req.PrimaryElectTabletAlias))
}
if _, ok := primaryTabletMap[primaryElectTabletAliasStr]; !ok {
if !req.Force {
return fmt.Errorf("primary-elect tablet %v is not a primary in the shard, use -force to proceed anyway", topoproto.TabletAliasString(req.PrimaryElectTabletAlias))
}
logger.Warningf("primary-elect tablet %v is not a primary in the shard, proceeding anyway as -force was used", topoproto.TabletAliasString(req.PrimaryElectTabletAlias))
}View on GitHub (pinned to 01a25a7d17)
Solutions
- List the shard's tablets (`vtctldclient GetTablets --keyspace ks --shard shard`) and use a valid alias.
- Correct typos or wrong-cluster/shard references in the alias.
- If the tablet was removed, first restore/replace the tablet then retry the PRS call.
Example fix
// before vtctldclient PlannedReparentShard commerce/0 --primary-elect-alias zone1-0000009999 // after vtctldclient PlannedReparentShard commerce/0 --primary-elect-alias zone1-0000000102
Defensive patterns
Strategy: validation
Validate before calling
alias := topoproto.TabletAliasString(req.PrimaryElectTabletAlias)
if _, ok := tabletMap[alias]; !ok {
return fmt.Errorf("tablet %s not in shard", alias)
} Prevention
- List shard tablets before choosing a primary-elect alias
- Never hardcode tablet aliases in scripts; fetch them from the topo
- Confirm the alias belongs to the target keyspace/shard
When it happens
Trigger: Calling PlannedReparentShard with req.PrimaryElectTabletAlias set to an alias that is not a tablet of the target shard (wrong shard, removed tablet, or mistyped alias).
Common situations: Copy-pasting an alias from another shard, referencing a tablet after it was decommissioned, or passing an empty alias.
Related errors
- primary-elect tablet %v is not the shard primary, use -force
- primary-elect tablet %v is not a primary in the shard, use -
- primary-elect tablet %v is not the only primary in the shard
- no app indicated
- tablet %v type change %v -> %v is not an allowed transition
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/97dd21754b7c3c71.
Report an issue: GitHub.