vitessio/vitess · error

cannot reshard streams with a mix of reference and sharded t

Error message

cannot reshard streams with a mix of reference and sharded tables: %v

What it means

blsIsReference determines whether a stream's BinlogSource filters reference or sharded tables. A reshard can only migrate streams that are homogeneous in this respect. If a stream's rules indicate sharded tables after a reference table was already seen, the operation is rejected with this error since reference and sharded streams require different handling in resharding.

Source

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

		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 := StreamTypeUnknown
	for _, rule := range bls.Filter.Rules {
		typ, err := rs.identifyRuleType(rule)
		if err != nil {
			return false, err
		}

		switch typ {
		case StreamTypeSharded:
			if streamType == StreamTypeReference {
				return false, fmt.Errorf("cannot reshard streams with a mix of reference and sharded tables: %v", bls)
			}
			streamType = StreamTypeSharded
		case StreamTypeReference:
			if streamType == StreamTypeSharded {
				return false, fmt.Errorf("cannot reshard streams with a mix of reference and sharded tables: %v", bls)
			}
			streamType = StreamTypeReference
		}
	}
	return streamType == StreamTypeReference, nil
}

func (rs *resharder) identifyRuleType(rule *binlogdatapb.Rule) (StreamType, error) {
	vtable, ok := rs.vschema.Tables[rule.Match]
	if !ok && !schema.IsInternalOperationTableName(rule.Match) {
		return 0, fmt.Errorf("table %v not found in vschema", rule.Match)
	}
	if vtable != nil && vtable.Type == vindexes.TypeReference {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Split the stream into separate workflows: one for reference tables, one for sharded tables.
  2. Update the stream's filter so its rules cover only one table type.
  3. Re-run the reshard/migration after the streams are homogeneous.

Example fix

// before: one stream mixing reference and sharded tables in rules
rules: [{match: "ref_table"}, {match: "sharded_table"}]
// after: separate streams
stream1 rules: [{match: "ref_table"}]
stream2 rules: [{match: "sharded_table"}]
Defensive patterns

Strategy: validation

Validate before calling

-- Check each stream's filter matches only one table type via the vschema
SELECT id, workflow, filter FROM _vt.vreplication; -- cross-check rule matches against vschema table types

Try / catch

if err != nil && strings.Contains(err.Error(), "mix of reference and sharded tables") {
    // split the offending stream's filter, then retry
}

Prevention

When it happens

Trigger: A single VReplication stream's BinlogSource rule list contains a mix of rules matching reference tables and rules matching sharded (non-reference) tables, detected while classifying streams during resharding.

Common situations: A filter (e.g. from a MoveTables workflow) was edited to add or remove tables changing its type; a workflow was configured against a schema where the same filter matches both reference and sharded tables; vschema changes reclassified tables.

Related errors


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