vitessio/vitess · error

streams are mismatched across source shards: %v

Error message

streams are mismatched across source shards: %v

What it means

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.

Source

Thrown at go/vt/wrangler/resharder.go:249

				continue
			}
			key := fmt.Sprintf("%s:%s:%s", workflow, bls.Keyspace, bls.Shard)
			if mustCreate {
				rs.refStreams[key] = &refStream{
					workflow:    workflow,
					bls:         &bls,
					cell:        row[2].ToString(),
					tabletTypes: row[3].ToString(),
				}
			} else {
				if !ref[key] {
					return fmt.Errorf("streams are mismatched across source shards for workflow: %s", workflow)
				}
				delete(ref, key)
			}
		}
		if len(ref) != 0 {
			return fmt.Errorf("streams are mismatched across source shards: %v", ref)
		}
		return nil
	})
	return err
}

// blsIsReference is partially copied from streamMigrater.templatize.
// It reuses the constants from that function also.
func (rs *resharder) blsIsReference(bls *binlogdatapb.BinlogSource) (bool, error) {
	streamType := workflow.StreamTypeUnknown
	for _, rule := range bls.Filter.Rules {
		typ, err := rs.identifyRuleType(rule)
		if err != nil {
			return false, err
		}

		switch typ {
		case workflow.StreamTypeSharded:

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Read the error output listing the missing streams (binlog source, cell, tablet types).
  2. 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.
  3. If recreating via tooling, ensure the shard is properly registered and primary-serving so VReplication can be set up there.
  4. Verify with `SELECT workflow, binlog_source, cell, tablet_types FROM _vt.vreplication` across all source shards before re-running the reshard.

Example fix

-- before: shard 1 has 1 stream, shard 0 has 2
-- recreate missing stream on shard 1 (or rerun MoveTables)
-- after: both shards report the same stream set
Defensive patterns

Strategy: validation

Validate before calling

perShard := map[string]int{} // shard -> stream count for workflow
for _, shard := range sourceShards { perShard[shard] = countStreams(shard, workflow) }
if len(uniqueCounts(perShard)) > 1 { return fmt.Errorf("stream counts differ across source shards") }

Type guard

func allShardsHaveStreams(perShard map[string]int) bool {
    want := maxCount(perShard)
    for _, n := range perShard { if n != want { return false } }
    return true
}

Try / catch

if err := wr.Reshard(...); err != nil {
    if strings.Contains(err.Error(), "streams are mismatched across source shards:") {
        // error body lists missing streams; recreate them and retry
        return recreateMissingStreams(ctx, err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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