vitessio/vitess · error

table %v not found in vschema

Error message

table %v not found in vschema

What it means

Thrown by resharder.identifyRuleType when a filter rule's Match table is not present in the keyspace's vschema and is not an internal operation table (e.g. _vt purposes). The resharder needs to know whether each rule targets a reference or sharded table, which it can only determine from the vschema entry.

Source

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

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

func (rs *resharder) identifyRuleType(rule *binlogdatapb.Rule) (workflow.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 {
		return workflow.StreamTypeReference, nil
	}
	// In this case, 'sharded' means that it's not a reference
	// table. We don't care about any other subtleties.
	return workflow.StreamTypeSharded, nil
}

func (rs *resharder) copySchema(ctx context.Context) error {
	oneSource := rs.sourceShards[0].PrimaryAlias
	err := rs.forAll(rs.targetShards, func(target *topo.ShardInfo) error {
		return rs.wr.CopySchemaShard(ctx, oneSource, []string{"/.*"}, nil, false, rs.keyspace, target.ShardName(), 1*time.Second, false)
	})
	return err
}

// createStreams creates all of the VReplication streams that

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Add the table to the keyspace's vschema (vtctl ApplyVSchema) so it is present in the Tables map
  2. Fix the rule.Match spelling to exactly match a table defined in the vschema
  3. Verify with vtctl GetVSchema <keyspace> that the table is listed
  4. If the table is intentional and internal, name it per the internal operation table naming convention so it is skipped

Example fix

// before: vschema has no 'custmers' table
{"rules": [{"match": "custmers"}]}
// after: correct the name or add the table to vschema
{"rules": [{"match": "customers"}]}
Defensive patterns

Strategy: validation

Validate before calling

vs, err := ts.GetVSchema(ctx, keyspace)
if err != nil { return err }
for _, rule := range filter.Rules {
    if _, ok := vs.Tables[rule.Match]; !ok && !schema.IsInternalOperationTableName(rule.Match) {
        return fmt.Errorf("table %s not in vschema for keyspace %s", rule.Match, keyspace)
    }
}

Type guard

func tableInVschema(vsch *vschemapb.Keyspace, match string) bool {
    _, ok := vsch.GetTables()[match]
    return ok
}

Prevention

When it happens

Trigger: Creating a Reshard/MoveTables workflow whose binlogdatapb.Rule.Match names a table absent from the vschema's Tables map; typos in the match name; rule matching a table not declared in the topocache/vschema for that keyspace.

Common situations: Table renamed or dropped but workflow filter still references the old name; vschema never updated after adding the table; misspelling in the rule; table lives in a different keyspace than the one the workflow targets.

Related errors


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