{"record":{"id":"8ca6e42533975721","repo":"vitessio/vitess","slug":"v-v-has-tables-that-are-not-in-the-vschema-v","errorCode":null,"errorMessage":"%v/%v has tables that are not in the vschema: %v","messagePattern":"(.+?)/(.+?) has tables that are not in the vschema: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/schema.go","lineNumber":164,"sourceCode":"\t\t\t\treturn\n\t\t\t}\n\t\t\treq := &tabletmanagerdatapb.GetSchemaRequest{ExcludeTables: excludeTables, IncludeViews: includeViews}\n\t\t\tprimarySchema, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, si.PrimaryAlias, req)\n\t\t\tif err != nil {\n\t\t\t\tshardFailures.RecordError(fmt.Errorf(\"GetSchema(%s, nil, %v, %v) (%v/%v) failed: %v\", si.PrimaryAlias.String(),\n\t\t\t\t\texcludeTables, includeViews, keyspace, shard, err,\n\t\t\t\t))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor _, tableDef := range primarySchema.TableDefinitions {\n\t\t\t\tif _, ok := vschm.Tables[tableDef.Name]; !ok {\n\t\t\t\t\tif !schema.IsInternalOperationTableName(tableDef.Name) {\n\t\t\t\t\t\tnotFoundTables = append(notFoundTables, tableDef.Name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(notFoundTables) > 0 {\n\t\t\t\tshardFailure := fmt.Errorf(\"%v/%v has tables that are not in the vschema: %v\", keyspace, shard, notFoundTables)\n\t\t\t\tshardFailures.RecordError(shardFailure)\n\t\t\t}\n\t\t}(shard)\n\t}\n\twg.Wait()\n\tif shardFailures.HasErrors() {\n\t\treturn fmt.Errorf(\"ValidateVSchema(%v, %v, %v, %v) failed: %v\", keyspace, shards, excludeTables, includeViews, shardFailures.Error().Error())\n\t}\n\treturn nil\n}\n\n// PreflightSchema will try a schema change on the remote tablet.\nfunc (wr *Wrangler) PreflightSchema(ctx context.Context, tabletAlias *topodatapb.TabletAlias, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) {\n\tti, err := wr.ts.GetTablet(ctx, tabletAlias)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetTablet(%v) failed: %v\", tabletAlias, err)\n\t}\n\treturn wr.tmc.PreflightSchema(ctx, ti.Tablet, changes)","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/schema.go#L146-L182","documentation":"During ValidateVSchema, tables found on a shard's primary are compared against the keyspace's vschema. Any table present in the physical schema but absent from the vschema is collected into notFoundTables, and this error is recorded listing them. Internal operation tables are excluded from the check. This indicates the vschema (VTGate routing config) is out of sync with the actual database schema.","triggerScenarios":"Running ValidateVSchema where one or more tables exist in MySQL on a shard primary (e.g. created by a migration or manually) but have no corresponding entry in the keyspace's vschema (missing table vindex entries or table sections in the vschema JSON).","commonSituations":"Manual DDL applied directly to MySQL without updating the vschema; an online migration created new tables; vschema JSON was never updated after adding tables; new application tables added during development.","solutions":["Add the missing tables to the keyspace's vschema (vtctldclient ApplyVSchema with an updated JSON).","If a table is intentionally not managed by Vitess, add it to the vschema as an unsharded table entry or verify it's an internal operation table.","Re-run ValidateVSchema to confirm the vschema and physical schemas agree.","If the table is obsolete, drop it from MySQL or ignore via internal-operation-table handling."],"exampleFix":"// before: vschema missing the table\n{\"tables\": {\"users\": {}}}\n// after: add the table reported by the error\n{\"tables\": {\"users\": {}, \"orders\": {}}}","handlingStrategy":"validation","validationCode":"vschm, err := ts.GetVSchema(ctx, ks)\nif err != nil { return err }\nschema, err := schematools.GetSchema(ctx, ts, tmc, primaryAlias, req)\nif err != nil { return err }\nfor _, td := range schema.TableDefinitions {\n\tif _, ok := vschm.Tables[td.Name]; !ok && !schema0.IsInternalOperationTableName(td.Name) {\n\t\treturn fmt.Errorf(\"table %s missing from vschema\", td.Name)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := wr.ValidateVSchema(ctx, ks, shards, nil, nil, true); err != nil {\n\tif strings.Contains(err.Error(), \"not in the vschema\") {\n\t\t// parse missing tables from the message and apply an updated vschema\n\t}\n}","preventionTips":["Apply all DDL through vreplication/VTGate-managed workflows so vschema stays in sync","Run ValidateVSchema in CI after schema migrations","Keep the vschema JSON under version control and update it with every new table"],"tags":["vschema","validation","schema-drift","routing"],"backgroundTag":"vschema-schema-mismatch","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}