{"record":{"id":"f331aa775e14ccc3","repo":"vitessio/vitess","slug":"more-than-one-target-for-source-table-s-s-and","errorCode":null,"errorMessage":"more than one target for source table %s: %s and %s","messagePattern":"more than one target for source table (.+?): (.+?) and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go","lineNumber":175,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\t\tif rule == nil {\n\t\t\tcontinue\n\t\t}\n\t\tcolInfos, ok := colInfoMap[tableName]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"table %s not found in schema\", tableName)\n\t\t}\n\t\ttablePlan, err := buildTablePlan(tableName, rule, colInfos, lastpk, stats, source, collationEnv, parser, vr.workflowConfig)\n\t\tif err != nil {\n\t\t\treturn nil, vterrors.Wrapf(err, \"failed to build table replication plan for %s table\", tableName)\n\t\t}\n\t\tif tablePlan == nil {\n\t\t\t// Table was excluded.\n\t\t\tcontinue\n\t\t}\n\t\tif dup, ok := plan.TablePlans[tablePlan.SendRule.Match]; ok {\n\t\t\treturn nil, fmt.Errorf(\"more than one target for source table %s: %s and %s\", tablePlan.SendRule.Match, dup.TargetName, tableName)\n\t\t}\n\t\tplan.VStreamFilter.Rules = append(plan.VStreamFilter.Rules, tablePlan.SendRule)\n\t\tplan.TargetTables[tableName] = tablePlan\n\t\tplan.TablePlans[tablePlan.SendRule.Match] = tablePlan\n\t}\n\treturn plan, nil\n}\n\n// MatchTable is similar to tableMatches and buildPlan defined in vstreamer/planbuilder.go.\nfunc MatchTable(tableName string, filter *binlogdatapb.Filter) (*binlogdatapb.Rule, error) {\n\tfor _, rule := range filter.Rules {\n\t\tswitch {\n\t\tcase strings.HasPrefix(rule.Match, \"/\"):\n\t\t\texpr := strings.Trim(rule.Match, \"/\")\n\t\t\tresult, err := regexp.MatchString(expr, tableName)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go#L157-L193","documentation":"buildReplicatorPlan enforces a 1:1 mapping between a source table (the SendRule.Match key) and a target table. When a second tablePlan resolves to the same source table match key, planning fails rather than silently merging or double-streaming rows to two targets.","triggerScenarios":"Two filter rules whose `match` patterns resolve to the same source table, e.g. one exact rule `t1` plus a wildcard `t*` that also matches t1, both producing a plan for the same SendRule.Match.","commonSituations":"Overlapping regex rules in a MoveTables Filter; adding a specific-table rule without removing an existing catch-all rule; copy-phase rules built by initTablesForCopy colliding with user-supplied rules.","solutions":["Review the Filter rules and remove/merge overlapping matches","Make wildcard rules more specific so they don't overlap exact matches","Order rules so the intended one wins and delete the redundant rule (first explicit rule should be the only one matching each table)"],"exampleFix":"// before\n\"rules\": [{\"match\": \"t*\", \"targetTable\": \"t\"}, {\"match\": \"t1\", \"targetTable\": \"t1\"}]\n// after\n\"rules\": [{\"match\": \"t1\", \"targetTable\": \"t1\"}, {\"match\": \"t2\", \"targetTable\": \"t2\"}]","handlingStrategy":"validation","validationCode":"seen := map[string]string{}\nfor _, r := range filter.Rules {\n    if prev, dup := seen[r.Match]; dup {\n        return fmt.Errorf(\"rule %q duplicates match already handled by %q\", r.TargetTable, prev)\n    }\n    seen[r.Match] = r.TargetTable\n}","typeGuard":"func hasOverlappingRules(rules []*Rule) bool {\n    matches := map[string]bool{}\n    for _, r := range rules {\n        if matches[r.Match] { return true }\n        matches[r.Match] = true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Audit Filter rules for overlapping regex patterns before MoveTables","Prefer explicit per-table rules over broad wildcards","Remove stale catch-all rules when adding specific ones"],"tags":["vreplication","filter-rules","duplicate-target","plan-builder"],"backgroundTag":"duplicate-filter-rule-target","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}