{"record":{"id":"f65cb1b6f2bb0099","repo":"vitessio/vitess","slug":"source-shard-v-is-not-in-serving-state","errorCode":null,"errorMessage":"source shard %v is not in serving state","messagePattern":"source shard (.+?) is not in serving state","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/resharder.go","lineNumber":97,"sourceCode":"\ttargets := req.GetTargetShards()\n\n\trs := &resharder{\n\t\ts:               s,\n\t\tkeyspace:        keyspace,\n\t\tworkflow:        workflow,\n\t\tsourcePrimaries: make(map[string]*topo.TabletInfo),\n\t\ttargetPrimaries: make(map[string]*topo.TabletInfo),\n\t\tcell:            cell,\n\t\ttabletTypes:     tabletTypes,\n\t\tworkflowOptions: req.GetWorkflowOptions(),\n\t}\n\tfor _, shard := range sources {\n\t\tsi, err := s.ts.GetShard(ctx, keyspace, shard)\n\t\tif err != nil {\n\t\t\treturn nil, vterrors.Wrapf(err, \"GetShard(%s) failed\", shard)\n\t\t}\n\t\tif !si.IsPrimaryServing {\n\t\t\treturn nil, fmt.Errorf(\"source shard %v is not in serving state\", shard)\n\t\t}\n\t\trs.sourceShards = append(rs.sourceShards, si)\n\t\tprimary, err := s.ts.GetTablet(ctx, si.PrimaryAlias)\n\t\tif err != nil {\n\t\t\treturn nil, vterrors.Wrapf(err, \"GetTablet(%s) failed\", si.PrimaryAlias)\n\t\t}\n\t\trs.sourcePrimaries[si.ShardName()] = primary\n\t}\n\tfor _, shard := range targets {\n\t\tsi, err := s.ts.GetShard(ctx, keyspace, shard)\n\t\tif err != nil {\n\t\t\treturn nil, vterrors.Wrapf(err, \"GetShard(%s) failed\", shard)\n\t\t}\n\t\tif si.PrimaryAlias == nil {\n\t\t\treturn nil, fmt.Errorf(\"target shard %v has no primary tablet\", shard)\n\t\t}\n\t\tif si.IsPrimaryServing {\n\t\t\treturn nil, fmt.Errorf(\"target shard %v is in serving state\", shard)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/resharder.go#L79-L115","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Restore the primary serving state on the shard: run `vtctl InitShardPrimary` (or PlannedReparentShard) to get a serving primary","Check shard state with `vtctl GetShard <keyspace>/<shard>` and fix IsPrimaryServing (e.g. via TabletExternallyReparented or RecomputeShardServingState)","Remove the non-serving shard from the reshard request or fix the shard before re-running ReshardCreate"],"exampleFix":"// before (source shard -80 has no serving primary)\nReshard --source-shards=0-,-80 --target-shards=0-40,40-\n// after\nvtctl PlannedReparentShard ks/-80 alias\nReshard --source-shards=0-,-80 --target-shards=0-40,40-","handlingStrategy":"validation","validationCode":"for _, shard := range sourceShards {\n    si, err := ts.GetShard(ctx, ks, shard)\n    if err != nil { return err }\n    if !si.IsPrimaryServing {\n        return fmt.Errorf(\"pre-check: source shard %s not serving; fix before Reshard\", shard)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := reshardCreate(ctx, req); err != nil {\n    if strings.Contains(err.Error(), \"not in serving state\") {\n        // reparent/repair the shard, then retry ReshardCreate\n    }\n    return err\n}","preventionTips":["Check shard serving states with GetShard before resharding","Ensure healthy primaries on all source shards (PlannedReparentShard as needed)","Automate a pre-flight shard health check in reshard runbooks"],"tags":["vitess","resharding","vreplication","shard-serving","topology"],"backgroundTag":"shard-not-serving","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}