{"record":{"id":"6ff3a76c971611a9","repo":"vitessio/vitess","slug":"cannot-migrate-streams-with-a-mix-of-reference-and","errorCode":null,"errorMessage":"cannot migrate streams with a mix of reference and sharded tables: %v","messagePattern":"cannot migrate streams with a mix of reference and sharded tables: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/stream_migrator.go","lineNumber":1091,"sourceCode":"/* templatizing */\n\nfunc (sm *StreamMigrator) templatize(ctx context.Context, tabletStreams []*VReplicationStream) ([]*VReplicationStream, error) {\n\tvar shardedStreams []*VReplicationStream\n\n\ttabletStreams = VReplicationStreams(tabletStreams).Copy().ToSlice()\n\tfor _, vrs := range tabletStreams {\n\t\tstreamType := StreamTypeUnknown\n\n\t\tfor _, rule := range vrs.BinlogSource.Filter.Rules {\n\t\t\ttyp, err := sm.templatizeRule(ctx, rule)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tswitch typ {\n\t\t\tcase StreamTypeSharded:\n\t\t\t\tif streamType == StreamTypeReference {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cannot migrate streams with a mix of reference and sharded tables: %v\", vrs.BinlogSource)\n\t\t\t\t}\n\t\t\t\tstreamType = StreamTypeSharded\n\t\t\tcase StreamTypeReference:\n\t\t\t\tif streamType == StreamTypeSharded {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cannot migrate streams with a mix of reference and sharded tables: %v\", vrs.BinlogSource)\n\t\t\t\t}\n\t\t\t\tstreamType = StreamTypeReference\n\t\t\t}\n\t\t}\n\n\t\tif streamType == StreamTypeSharded {\n\t\t\tshardedStreams = append(shardedStreams, vrs)\n\t\t}\n\t}\n\n\treturn shardedStreams, nil\n}\n","sourceCodeStart":1073,"sourceCodeEnd":1109,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/stream_migrator.go#L1073-L1109","documentation":"During templatize (part of stream migration), each filter rule of a stream is classified as StreamTypeSharded or StreamTypeReference via templatizeRule. This error is thrown when a sharded-typed stream also contains rules for reference (non-sharded) tables — a stream mixing both kinds cannot be templatized into per-shard keyrange templates and migrated. This is the first of the two symmetric check sites (sharded encountered while stream was already reference).","triggerScenarios":"Calling BuildStreamMigrator / StopStreams / LegacyStopStreams where a workflow's BinlogSource.Filter contains rules whose tables resolve to both vindexes.TypeReference and sharded types, with a reference-type rule appearing after (or while) a sharded rule set streamType=Sharded... precisely: a sharded-typed rule is processed after a reference-typed rule (streamType==Reference) — wait, line 1091 fires when a StreamTypeSharded rule arrives while streamType is Reference; line 1096 is its mirror.","commonSituations":"A MoveTables or Materialize workflow was configured to replicate both sharded tables and reference tables in one stream; a table's vindex type changed (converted to reference table) after the workflow started; user added a reference table to an existing sharded workflow's filter.","solutions":["Split the workflow: keep sharded tables in one vreplication workflow and reference tables in a separate one, then migrate each separately.","Move reference-table replication out of the stream being migrated (e.g. cancel those rules or use a dedicated reference-tables workflow).","Check whether a table type changed (`show vitess_keyspaces` / vschema): if a table was recently converted to a reference table, recreate the workflow consistent with the new type.","Re-run the migration with a filter containing only same-type tables."],"exampleFix":"// before: one workflow with rules for sharded 'user' and reference 'product'\n// after: two workflows\n// workflowA: filter rules for sharded tables only\n// workflowB: filter rules for reference tables only (migrated separately)","handlingStrategy":"validation","validationCode":"// Before migrating, check each workflow's tables resolve to a single type\n// in the vschema: all sharded OR all reference.\n// SHOW VSCHEMA TABLES; -> classify each filtered table by vindex type","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep reference tables in dedicated Materialize/MoveTables workflows, never mixed with sharded tables.","Review vschema changes (table type conversions) before running stream migration.","Document per-workflow table lists and validate them before cutover."],"tags":["vitess","vreplication","sharding","reference-tables","config-error"],"backgroundTag":"mixed-sharded-reference-streams","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}