vitessio/vitess · error

GetSchema(%v, %v, %v, %v) failed: %v

Error message

GetSchema(%v, %v, %v, %v) failed: %v

What it means

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.

Source

Thrown at go/vt/wrangler/schema.go:225

	}

	if destShardInfo.PrimaryAlias == nil {
		return 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)
	}

	diffs, err := schematools.CompareSchemas(ctx, wr.ts, wr.tmc, sourceTabletAlias, destShardInfo.PrimaryAlias, tables, excludeTables, includeViews)
	if err != nil {
		return fmt.Errorf("CopySchemaShard failed because schemas could not be compared initially: %v", err)
	}
	if diffs == nil {
		// Return early because dest has already the same schema as source.
		return nil
	}

	req := &tabletmanagerdatapb.GetSchemaRequest{Tables: tables, ExcludeTables: excludeTables, IncludeViews: includeViews}
	sourceSd, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, sourceTabletAlias, req)
	if err != nil {
		return fmt.Errorf("GetSchema(%v, %v, %v, %v) failed: %v", sourceTabletAlias, tables, excludeTables, includeViews, err)
	}

	createSQLstmts := tmutils.SchemaDefinitionToSQLStrings(sourceSd)

	destTabletInfo, err := wr.ts.GetTablet(ctx, destShardInfo.PrimaryAlias)
	if err != nil {
		return fmt.Errorf("GetTablet(%v) failed: %v", destShardInfo.PrimaryAlias, err)
	}
	for _, createSQL := range createSQLstmts {
		err = wr.applySQLShard(ctx, destTabletInfo, createSQL)
		if err != nil {
			return fmt.Errorf("creating a table failed."+
				" Most likely some tables already exist on the destination and differ from the source."+
				" Please remove all to be copied tables from the destination manually and run this command again."+
				" Full error: %v", err)
		}
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the source tablet is running and reachable via vtctldclient GetTablet <alias>.
  2. Retry CopySchemaShard once the source tablet is healthy; transient RPC failures are common.
  3. Check vtctld and tablet logs for the underlying GetSchema error (connection, timeout, or permission issue).
  4. If the table lists are wrong, fix the --tables/--exclude-tables/--include-views flags and rerun.

Example fix

// before (tablet down)
sourceSd, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, sourceTabletAlias, req)
if err != nil { return fmt.Errorf("GetSchema(...) failed: %v", err) }
// after (caller-side guard)
if _, err := wr.ts.GetTablet(ctx, sourceTabletAlias); err != nil {
    return fmt.Errorf("source tablet unavailable: %v", err)
}
Defensive patterns

Strategy: validation

Validate before calling

tablet, err := wr.ts.GetTablet(ctx, sourceTabletAlias)
if err != nil || !isRunning(tablet) {
    return fmt.Errorf("source tablet %s unavailable: %v", sourceTabletAlias, err)
}

Type guard

func tabletReachable(t *topo.TabletInfo) bool {
    return t != nil && t.Tablet != nil && t.Tablet.MysqlHostname != ""
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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