{"record":{"id":"5cfd162de5c2ee93","repo":"vitessio/vitess","slug":"no-vschema-definition-for-table-v","errorCode":null,"errorMessage":"no vschema definition for table %v","messagePattern":"no vschema definition for table (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/keyspace_id_resolver.go","lineNumber":73,"sourceCode":"// gets the keyspace part, and uses it to find the column name.\nfunc newKeyspaceIDResolverFactoryV3(ctx context.Context, ts *topo.Server, keyspace string, cell string, parser *sqlparser.Parser) (keyspaceIDResolverFactory, error) {\n\tsrvVSchema, err := ts.GetSrvVSchema(ctx, cell)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkschema, ok := srvVSchema.Keyspaces[keyspace]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"SrvVSchema has no entry for keyspace %v\", keyspace)\n\t}\n\tkeyspaceSchema, err := vindexes.BuildKeyspaceSchema(kschema, keyspace, parser)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot build vschema for keyspace %v: %v\", keyspace, err)\n\t}\n\treturn func(table *schema.Table) (int, keyspaceIDResolver, error) {\n\t\t// Find the v3 schema.\n\t\ttableSchema, ok := keyspaceSchema.Tables[table.Name.String()]\n\t\tif !ok {\n\t\t\treturn -1, nil, fmt.Errorf(\"no vschema definition for table %v\", table.Name)\n\t\t}\n\n\t\t// use the lowest cost unique vindex as the sharding key\n\t\tcolVindex, err := vindexes.FindVindexForSharding(table.Name.String(), tableSchema.ColumnVindexes)\n\t\tif err != nil {\n\t\t\treturn -1, nil, err\n\t\t}\n\n\t\t// TODO @rafael - when rewriting the mapping function, this will need to change.\n\t\t// for now it's safe to assume the sharding key will be always on index 0.\n\t\tshardingColumnName := colVindex.Columns[0].String()\n\t\tfor i, col := range table.Fields {\n\t\t\tif strings.EqualFold(col.Name, shardingColumnName) {\n\t\t\t\t// We found the column.\n\t\t\t\treturn i, &keyspaceIDResolverFactoryV3{\n\t\t\t\t\t// Only SingleColumn vindexes are returned by FindVindexForSharding.\n\t\t\t\t\tvindex: colVindex.Vindex.(vindexes.SingleColumn),\n\t\t\t\t}, nil","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/keyspace_id_resolver.go#L55-L91","documentation":"Returned by the binlog keyspace ID resolver when a row's table has no entry in the vschema, so no keyspace ID mapping can be derived for the row.","triggerScenarios":"Streaming a keyrange where a DML targets a table absent from keyspaceSchema.Tables (table missing from vschema's table definitions).","commonSituations":"Table added to MySQL but vschema never updated; unsharded-style schema used in a sharded keyspace; system/temp tables not declared in vschema.","solutions":["Add the table (with its column vindexes) to the keyspace vschema via vtctldclient ApplyVSchema.","Rebuild the SrvVSchema and restart the streamer.","Exclude undeclared tables from the filter rules if they should not be streamed."],"exampleFix":"// before\n{\"tables\":{}}\n// after\n{\"tables\":{\"t1\":{\"column_vindexes\":[{\"column\":\"id\",\"name\":\"h\"}]}}}","handlingStrategy":"validation","validationCode":"srv, _ := ts.GetSrvVSchema(ctx, cell)\nks := srv.Keyspaces[keyspace]\nfor _, tbl := range tablesToStream {\n\tif _, ok := ks.Tables[tbl]; !ok {\n\t\treturn fmt.Errorf(\"table %s missing from vschema for %s\", tbl, keyspace)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := streamKeyRange(ctx, kr); err != nil {\n\tif strings.Contains(err.Error(), \"no vschema definition for table\") {\n\t\t// add table to vschema, then ApplyVSchema + RebuildKeyspaceGraph\n\t}\n\treturn err\n}","preventionTips":["Keep vschema in sync with the MySQL schema after every migration.","Declare all streamed tables (with column vindexes) in the keyspace vschema.","Filter out tables that intentionally have no vschema entry."],"tags":["vschema","table","binlog","sharding"],"backgroundTag":"no-vschema-table-definition","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}