vitessio/vitess · error

failed to get schema from tablet %v. err: %v

Error message

failed to get schema from tablet %v. err: %v

What it means

CompareSchemas fetches the schema of the SOURCE tablet via GetSchema (an RPC to its tabletmanager) and wraps any failure with this message identifying the source tablet alias. It means the schema could not be retrieved, so the diff cannot proceed and the whole call returns an error.

Source

Thrown at go/vt/vtctl/schematools/diff.go:48

// CompareSchemas returns (nil, nil) if the schema of the two tablets match. If
// there are diffs, they are returned as (diffs []string, nil).
//
// If fetching the schema for either tablet fails, a non-nil error is returned.
func CompareSchemas(
	ctx context.Context,
	ts *topo.Server,
	tmc tmclient.TabletManagerClient,
	source *topodatapb.TabletAlias,
	dest *topodatapb.TabletAlias,
	tables []string,
	excludeTables []string,
	includeViews bool,
) (diffs []string, err error) {
	req := &tabletmanagerdatapb.GetSchemaRequest{Tables: tables, ExcludeTables: excludeTables, IncludeViews: includeViews}
	sourceSchema, err := GetSchema(ctx, ts, tmc, source, req)
	if err != nil {
		return nil, fmt.Errorf("failed to get schema from tablet %v. err: %v", source, err)
	}

	destSchema, err := GetSchema(ctx, ts, tmc, dest, req)
	if err != nil {
		return nil, fmt.Errorf("failed to get schema from tablet %v. err: %v", dest, err)
	}

	return tmutils.DiffSchemaToArray("source", sourceSchema, "dest", destSchema), nil
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the source tablet alias is valid and serving: `vtctldclient GetTablets`.
  2. Run `vtctldclient GetSchema <source-alias>` manually to see the underlying RPC/MySQL error.
  3. Check the source tablet's vttablet and mysqld are running and reachable.
  4. Fix MySQL grants for the vttablet user if the inner error indicates access denied.

Example fix

// before: failing call
CompareSchemas(ctx, ts, tmc, badAlias, dest, tables, excludeTables, includeViews)
// after: validate alias first
if _, err := ts.GetTablet(ctx, source); err != nil { return fmt.Errorf("source tablet %s not found: %w", source, err) }
Defensive patterns

Strategy: validation

Validate before calling

if _, err := ts.GetTablet(ctx, source); err != nil {
  return fmt.Errorf("source tablet %s unavailable: %w", source, err)
}

Try / catch

if err := compareSchemas(...); err != nil {
  if strings.Contains(err.Error(), "failed to get schema from tablet") {
    log.Errorf("schema fetch failed; verify tablet is serving: %v", err)
  }
}

Prevention

When it happens

Trigger: Calling CompareSchemas (directly or via CopySchemaShard) where `GetSchema(ctx, ts, tmc, source, req)` fails: source tablet alias invalid/not in topo, tablet unreachable, or the GetSchema RPC returns an error (e.g. MySQL error reading information_schema, permission denied).

Common situations: CopySchemaShard run with a misspelled or dead source tablet/shard alias; source tablet's mysqld down; vttablet lacking MySQL privileges to read schema; tablet was recommissioned under a different alias.

Related errors


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