{"record":{"id":"c6d69ac674159cc4","repo":"vitessio/vitess","slug":"streams-are-mismatched-across-source-shards-v-c6d69a","errorCode":null,"errorMessage":"streams are mismatched across source shards: %v","messagePattern":"streams are mismatched across source shards: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/resharder.go","lineNumber":249,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\t\t\tkey := fmt.Sprintf(\"%s:%s:%s\", workflow, bls.Keyspace, bls.Shard)\n\t\t\tif mustCreate {\n\t\t\t\trs.refStreams[key] = &refStream{\n\t\t\t\t\tworkflow:    workflow,\n\t\t\t\t\tbls:         &bls,\n\t\t\t\t\tcell:        row[2].ToString(),\n\t\t\t\t\ttabletTypes: row[3].ToString(),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif !ref[key] {\n\t\t\t\t\treturn fmt.Errorf(\"streams are mismatched across source shards for workflow: %s\", workflow)\n\t\t\t\t}\n\t\t\t\tdelete(ref, key)\n\t\t\t}\n\t\t}\n\t\tif len(ref) != 0 {\n\t\t\treturn fmt.Errorf(\"streams are mismatched across source shards: %v\", ref)\n\t\t}\n\t\treturn nil\n\t})\n\treturn err\n}\n\n// blsIsReference is partially copied from streamMigrater.templatize.\n// It reuses the constants from that function also.\nfunc (rs *resharder) blsIsReference(bls *binlogdatapb.BinlogSource) (bool, error) {\n\tstreamType := workflow.StreamTypeUnknown\n\tfor _, rule := range bls.Filter.Rules {\n\t\ttyp, err := rs.identifyRuleType(rule)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tswitch typ {\n\t\tcase workflow.StreamTypeSharded:","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/resharder.go#L231-L267","documentation":"This is the complementary direction of the stream-mismatch check: after processing all rows on a shard, if any reference entries remain unmatched (`len(ref) != 0`), the shard is missing streams that other source shards have. The remaining unmatched entries are printed in the error to show exactly what is missing.","triggerScenarios":"Reshard run where one source shard has fewer VReplication streams for a workflow than the reference shard — the leftover `ref` set is reported with this message.","commonSituations":"A shard's stream crashed and was deleted and not recreated; a partial MoveTables that only created streams on some shards; manual cleanup removed a stream on one shard; a shard was added after the workflow started and never got its streams.","solutions":["Read the error output listing the missing streams (binlog source, cell, tablet types).","Recreate the missing streams on the deficient shard — ideally by deleting the workflow and re-running the original MoveTables/Reshard creation so all shards get identical streams.","If recreating via tooling, ensure the shard is properly registered and primary-serving so VReplication can be set up there.","Verify with `SELECT workflow, binlog_source, cell, tablet_types FROM _vt.vreplication` across all source shards before re-running the reshard."],"exampleFix":"-- before: shard 1 has 1 stream, shard 0 has 2\n-- recreate missing stream on shard 1 (or rerun MoveTables)\n-- after: both shards report the same stream set","handlingStrategy":"validation","validationCode":"perShard := map[string]int{} // shard -> stream count for workflow\nfor _, shard := range sourceShards { perShard[shard] = countStreams(shard, workflow) }\nif len(uniqueCounts(perShard)) > 1 { return fmt.Errorf(\"stream counts differ across source shards\") }","typeGuard":"func allShardsHaveStreams(perShard map[string]int) bool {\n    want := maxCount(perShard)\n    for _, n := range perShard { if n != want { return false } }\n    return true\n}","tryCatchPattern":"if err := wr.Reshard(...); err != nil {\n    if strings.Contains(err.Error(), \"streams are mismatched across source shards:\") {\n        // error body lists missing streams; recreate them and retry\n        return recreateMissingStreams(ctx, err)\n    }\n    return err\n}","preventionTips":["Recreate workflows wholly rather than partially when streams fail on some shards","Ensure newly added shards get streams before starting dependent reshards","Monitor vreplication stream counts per shard for drift"],"tags":["vreplication","reshard","consistency","missing-stream"],"backgroundTag":"vreplication-stream-mismatch","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}