{"record":{"id":"eac94a48d6aa930c","repo":"vitessio/vitess","slug":"source-shard-v-is-not-in-serving-state-eac94a","errorCode":null,"errorMessage":"source shard %v is not in serving state","messagePattern":"source shard (.+?) is not in serving state","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/resharder.go","lineNumber":124,"sourceCode":"}\n\nfunc (wr *Wrangler) buildResharder(ctx context.Context, keyspace, workflow string, sources, targets []string, cell, tabletTypes string) (*resharder, error) {\n\trs := &resharder{\n\t\twr:              wr,\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}\n\tfor _, shard := range sources {\n\t\tsi, err := wr.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 := wr.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 := wr.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(\"target shard %v is in serving state\", shard)\n\t\t}\n\t\trs.targetShards = append(rs.targetShards, si)\n\t\tprimary, err := wr.ts.GetTablet(ctx, si.PrimaryAlias)","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/resharder.go#L106-L142","documentation":"During reshard setup, buildResharder requires every source shard's primary to be serving (`IsPrimaryServing` true in the topo). If a source shard is not serving, the reshard would silently lose binlog/VReplication data, so it aborts with this error before starting.","triggerScenarios":"Calling Reshard (e.g. `vtctlclient Reshard <keyspace>.<workflow> <source_shards> <target_shards>`) while one of the source shards has IsPrimaryServing=false — primary tablet down, serving removed via SetShardIsPrimaryServing, or shard mid-reparent.","commonSituations":"Primary tablet crashed and was not replaced before starting the reshard; an operator disabled serving on a shard during maintenance and forgot to re-enable; tablet registered but not yet serving after provisioning.","solutions":["Check `vtctlclient GetShard <keyspace>/<shard>` for IsPrimaryServing on each source shard.","If serving was disabled intentionally, re-enable: `vtctlclient SetShardIsPrimaryServing <keyspace>/<shard> true`.","If the primary tablet is down, repair it (restart vttablet, run reparent) until the shard serves.","Re-run the Reshard command once all source shards report serving=true."],"exampleFix":"// before\n$ vtctlclient SetShardIsPrimaryServing commerce/0 false\n// after\n$ vtctlclient SetShardIsPrimaryServing commerce/0 true\n$ vtctlclient Reshard commerce.reshard - -80,80-","handlingStrategy":"validation","validationCode":"for _, shard := range sourceShards {\n    si, err := ts.GetShard(ctx, keyspace, shard)\n    if err != nil { return err }\n    if !si.IsPrimaryServing {\n        return fmt.Errorf(\"pre-flight: source shard %s is not serving\", shard)\n    }\n}","typeGuard":"func sourceIsServing(si *topo.ShardInfo) bool { return si.IsPrimaryServing }","tryCatchPattern":"err := wr.Reshard(ctx, keyspace, workflow, sources, targets, opts...)\nif err != nil && strings.Contains(err.Error(), \"not in serving state\") {\n    log.Error(\"source shard must serve before reshard\", slog.Any(\"error\", err))\n    // repair serving state then retry\n}","preventionTips":["Check GetShard serving flags as a preflight step before every Reshard","Alert on shards with IsPrimaryServing=false","Complete reparents/repairs before starting reshard operations"],"tags":["reshard","vreplication","serving","shard"],"backgroundTag":"shard-not-serving","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}