vitessio/vitess · error

source shard %v is not in serving state

Error message

source shard %v is not in serving state

What it means

buildResharder validates every source shard before creating the resharding workflow. Each source shard's primary must be serving; if si.IsPrimaryServing is false, the resharder cannot read from that shard and this error is returned, listing the offending shard.

Source

Thrown at go/vt/vtctl/workflow/resharder.go:97

	targets := req.GetTargetShards()

	rs := &resharder{
		s:               s,
		keyspace:        keyspace,
		workflow:        workflow,
		sourcePrimaries: make(map[string]*topo.TabletInfo),
		targetPrimaries: make(map[string]*topo.TabletInfo),
		cell:            cell,
		tabletTypes:     tabletTypes,
		workflowOptions: req.GetWorkflowOptions(),
	}
	for _, shard := range sources {
		si, err := s.ts.GetShard(ctx, keyspace, shard)
		if err != nil {
			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)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Restore the primary serving state on the shard: run `vtctl InitShardPrimary` (or PlannedReparentShard) to get a serving primary
  2. Check shard state with `vtctl GetShard <keyspace>/<shard>` and fix IsPrimaryServing (e.g. via TabletExternallyReparented or RecomputeShardServingState)
  3. Remove the non-serving shard from the reshard request or fix the shard before re-running ReshardCreate

Example fix

// before (source shard -80 has no serving primary)
Reshard --source-shards=0-,-80 --target-shards=0-40,40-
// after
vtctl PlannedReparentShard ks/-80 alias
Reshard --source-shards=0-,-80 --target-shards=0-40,40-
Defensive patterns

Strategy: validation

Validate before calling

for _, shard := range sourceShards {
    si, err := ts.GetShard(ctx, ks, shard)
    if err != nil { return err }
    if !si.IsPrimaryServing {
        return fmt.Errorf("pre-check: source shard %s not serving; fix before Reshard", shard)
    }
}

Try / catch

if _, err := reshardCreate(ctx, req); err != nil {
    if strings.Contains(err.Error(), "not in serving state") {
        // reparent/repair the shard, then retry ReshardCreate
    }
    return err
}

Prevention

When it happens

Trigger: ReshardCreate is called while one of the specified source shards has its primary not serving (e.g. primary is down, shard is in a failed/non-serving state in the topo).

Common situations: Source primary tablet down or not yet promoted; shard intentionally set non-serving during a prior maintenance; fresh shard never initialized; Tablets removed without updating serving state.

Related errors


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