vitessio/vitess · error

GetVSchema(keyspace = )

Error message

GetVSchema(keyspace = %s): %w

What it means

For each keyspace in a cluster, GetVSchemas calls c.GetVSchema to load its vschema; a per-keyspace failure is recorded with this wrapper naming the keyspace and embedding the cause. The errors accumulate in a per-cluster recorder and ultimately fail that cluster's vschema aggregation.

Solutions

  1. Read the wrapped message to find the exact keyspace and cause
  2. Validate the vschema JSON for that keyspace (vtctldclient GetVSchema / jq .)
  3. Re-apply a valid vschema with vtctldclient ApplyVSchema if it is corrupt
  4. Check topo health if the read itself failed

Example fix

// before
vschema, err := c.GetVSchema(ctx, keyspace.Name)
if err != nil {
	clusterRec.RecordError(fmt.Errorf("GetVSchema(keyspace = %s): %w", keyspace.Name, err))
	return
}
// after: fix invalid vschema JSON in topo, then same call succeeds
vschema, err := c.GetVSchema(ctx, keyspace.Name)
if err != nil {
	clusterRec.RecordError(fmt.Errorf("GetVSchema(keyspace = %s): %w", keyspace.Name, err))
	return
}
Defensive patterns

Strategy: validation

Validate before calling

// validate vschema JSON before relying on aggregation
raw, err := vtctldClient.GetVSchema(ctx, &vtctldatapb.GetVSchemaRequest{Keyspace: ks})
if err != nil || raw.VSchema == nil {
	log.Printf("keyspace %s vschema unreadable: %v", ks, err)
}

Type guard

func vschemaErrors(clusterRec concurrency.AllErrorRecorder) bool { return clusterRec.HasErrors() }

Try / catch

resp, err := client.GetVSchemas(ctx, req)
if err != nil {
	if strings.Contains(err.Error(), "GetVSchema(keyspace = ") {
		// extract keyspace; validate/fix its vschema in topo
	}
	return err
}

Prevention

When it happens

Trigger: Calling GetVSchemas when c.GetVSchema fails for a keyspace: the vschema is invalid JSON in the topo, the topo read fails, or vtctld returns an error for that keyspace.

Common situations: Hand-edited vschema JSON with syntax errors in the topo; keyspace deleted between GetKeyspaces and GetVSchema; topo connectivity problems; permission issues reading topo keys.

Related errors


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

Appendix: source

Thrown at go/vt/vtadmin/api.go:1672

			}

			getKeyspacesSpan.Finish()

			var (
				clusterM        sync.Mutex
				clusterWG       sync.WaitGroup
				clusterRec      concurrency.AllErrorRecorder
				clusterVSchemas = make([]*vtadminpb.VSchema, 0, len(keyspaces.Keyspaces))
			)

			for _, keyspace := range keyspaces.Keyspaces {
				clusterWG.Add(1)

				go func(keyspace *vtctldatapb.Keyspace) {
					defer clusterWG.Done()
					vschema, err := c.GetVSchema(ctx, keyspace.Name)
					if err != nil {
						clusterRec.RecordError(fmt.Errorf("GetVSchema(keyspace = %s): %w", keyspace.Name, err))
						return
					}

					clusterM.Lock()
					clusterVSchemas = append(clusterVSchemas, vschema)
					clusterM.Unlock()
				}(keyspace)
			}

			clusterWG.Wait()

			if clusterRec.HasErrors() {
				rec.RecordError(fmt.Errorf("GetVSchemas(cluster = %s): %w", c.ID, clusterRec.Error()))
				return
			}

			m.Lock()
			vschemas = append(vschemas, clusterVSchemas...)

View on GitHub (pinned to 01a25a7d17)