vitessio/vitess · error

GetVSchema(%s) failed: %v

Error message

GetVSchema(%s) failed: %v

What it means

Returned by ValidateVSchema when reading the keyspace's vschema from the topo (wr.ts.GetVSchema) fails. The validation compares each primary tablet's schema against the vschema, so it cannot proceed without the vschema record. Keyspace name and cause are embedded.

Source

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

		SkipNoPrimary:  skipNoPrimary,
	})

	for _, result := range res.Results {
		wr.Logger().Printf("%s\n", result)
	}

	if len(res.Results) > 0 {
		return fmt.Errorf("schema diffs: %v", res.Results)
	}

	return err
}

// ValidateVSchema compares the schema of each primary tablet in "keyspace/shards..." to the vschema and errs if there are differences
func (wr *Wrangler) ValidateVSchema(ctx context.Context, keyspace string, shards []string, excludeTables []string, includeViews bool) error {
	vschm, err := wr.ts.GetVSchema(ctx, keyspace)
	if err != nil {
		return fmt.Errorf("GetVSchema(%s) failed: %v", keyspace, err)
	}

	shardFailures := concurrency.AllErrorRecorder{}
	var wg sync.WaitGroup
	wg.Add(len(shards))

	for _, shard := range shards {
		go func(shard string) {
			defer wg.Done()
			notFoundTables := []string{}
			si, err := wr.ts.GetShard(ctx, keyspace, shard)
			if err != nil {
				shardFailures.RecordError(fmt.Errorf("GetShard(%v, %v) failed: %v", keyspace, shard, err))
				return
			}
			req := &tabletmanagerdatapb.GetSchemaRequest{ExcludeTables: excludeTables, IncludeViews: includeViews}
			primarySchema, err := schematools.GetSchema(ctx, wr.ts, wr.tmc, si.PrimaryAlias, req)
			if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check the keyspace name is correct and the vschema exists (vtctldclient GetVSchema <keyspace>)
  2. Verify topo server health and connectivity from vtctld
  3. If the vschema is missing/corrupt, re-apply a valid one (vtctldclient ApplyVSchema --vschema ...)
  4. Retry after transient topo issues are resolved

Example fix

// before: vschema missing for keyspace
// after: create it
vtctldclient ApplyVSchema --vschema '{"sharded": true, "vindexes": {...}}' commerce
Defensive patterns

Strategy: validation

Validate before calling

vs, err := ts.GetVSchema(ctx, keyspace)
if err != nil { return fmt.Errorf("cannot validate vschema: %w", err) }
if vs == nil || len(vs.GetTables()) == 0 { return fmt.Errorf("keyspace %s has no usable vschema", keyspace) }

Type guard

func vschemaReadable(ctx context.Context, ts topoclient.Server, keyspace string) bool {
    vs, err := ts.GetVSchema(ctx, keyspace)
    return err == nil && vs != nil
}

Try / catch

err := wr.ValidateVSchema(ctx, ks, shards, nil, true)
if err != nil && strings.Contains(err.Error(), "GetVSchema") {
    // check topo health / re-apply vschema, then retry
}

Prevention

When it happens

Trigger: ValidateVSchema or ValidateSchemaShard/ValidateSchemaKeyspace with includeVSchema=true, when the topo GetVSchema call errors: topo unavailable, keyspace record missing, or corrupted/unparsable vschema stored in the topo.

Common situations: Topo server outage; keyspace never had a vschema created; vschema JSON corrupted by a bad ApplyVSchema; typo in keyspace name.

Related errors


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