{"record":{"id":"f988beb3b7ee9c25","repo":"vitessio/vitess","slug":"getschema-v-v-v-v-failed-v","errorCode":null,"errorMessage":"GetSchema(%v, %v, %v, %v) failed: %v","messagePattern":"GetSchema\\((.+?), (.+?), (.+?), (.+?)\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/schema.go","lineNumber":225,"sourceCode":"\t}\n\n\tif destShardInfo.PrimaryAlias == nil {\n\t\treturn fmt.Errorf(\"no primary in shard record %v/%v. Consider running 'vtctl InitShardPrimary' in case of a new shard or reparenting the shard to fix the topology data\", destKeyspace, destShard)\n\t}\n\n\tdiffs, err := schematools.CompareSchemas(ctx, wr.ts, wr.tmc, sourceTabletAlias, destShardInfo.PrimaryAlias, tables, excludeTables, includeViews)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CopySchemaShard failed because schemas could not be compared initially: %v\", err)\n\t}\n\tif diffs == nil {\n\t\t// Return early because dest has already the same schema as source.\n\t\treturn nil\n\t}\n\n\treq := &tabletmanagerdatapb.GetSchemaRequest{Tables: tables, ExcludeTables: excludeTables, IncludeViews: includeViews}\n\tsourceSd, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, sourceTabletAlias, req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetSchema(%v, %v, %v, %v) failed: %v\", sourceTabletAlias, tables, excludeTables, includeViews, err)\n\t}\n\n\tcreateSQLstmts := tmutils.SchemaDefinitionToSQLStrings(sourceSd)\n\n\tdestTabletInfo, err := wr.ts.GetTablet(ctx, destShardInfo.PrimaryAlias)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetTablet(%v) failed: %v\", destShardInfo.PrimaryAlias, err)\n\t}\n\tfor _, createSQL := range createSQLstmts {\n\t\terr = wr.applySQLShard(ctx, destTabletInfo, createSQL)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"creating a table failed.\"+\n\t\t\t\t\" Most likely some tables already exist on the destination and differ from the source.\"+\n\t\t\t\t\" Please remove all to be copied tables from the destination manually and run this command again.\"+\n\t\t\t\t\" Full error: %v\", err)\n\t\t}\n\t}\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/schema.go#L207-L243","documentation":"Wrangler's CopySchemaShard calls schematools.GetSchema on the source tablet to fetch its schema definition before copying it to the destination shard. If that topo/tablet-manager RPC fails for any reason (tablet unreachable, RPC error, bad alias), the error is wrapped with the tablet alias and the table/exclude/includeViews parameters so you can see exactly which request failed.","triggerScenarios":"vtctldclient CopySchemaShard is invoked and the GetSchema RPC to the source tablet's tabletmanager fails: tablet is down, tabletmanager RPC times out, the tablet alias doesn't resolve, or the tablet rejects the schema request.","commonSituations":"Source tablet was recently restarted or demoted; network partition between vtctld and the tablet; schema sync is being run during a resharding window when tablets are moving; typos in the keyspace/shard resolving to a stale alias.","solutions":["Verify the source tablet is running and reachable via vtctldclient GetTablet <alias>.","Retry CopySchemaShard once the source tablet is healthy; transient RPC failures are common.","Check vtctld and tablet logs for the underlying GetSchema error (connection, timeout, or permission issue).","If the table lists are wrong, fix the --tables/--exclude-tables/--include-views flags and rerun."],"exampleFix":"// before (tablet down)\nsourceSd, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, sourceTabletAlias, req)\nif err != nil { return fmt.Errorf(\"GetSchema(...) failed: %v\", err) }\n// after (caller-side guard)\nif _, err := wr.ts.GetTablet(ctx, sourceTabletAlias); err != nil {\n    return fmt.Errorf(\"source tablet unavailable: %v\", err)\n}","handlingStrategy":"validation","validationCode":"tablet, err := wr.ts.GetTablet(ctx, sourceTabletAlias)\nif err != nil || !isRunning(tablet) {\n    return fmt.Errorf(\"source tablet %s unavailable: %v\", sourceTabletAlias, err)\n}","typeGuard":"func tabletReachable(t *topo.TabletInfo) bool {\n    return t != nil && t.Tablet != nil && t.Tablet.MysqlHostname != \"\"\n}","tryCatchPattern":null,"preventionTips":["Check source tablet health before CopySchemaShard.","Avoid running schema copies during reparents or tablet restarts.","Monitor vtctld-to-tabletmanager connectivity."],"tags":["go","topology","tabletmanager","schema-copy"],"backgroundTag":"tablet-rpc-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}