vitessio/vitess · error

ErrNoTablet

ErrNoTablet

Error message

%w for keyspace %s

What it means

When fetching a keyspace's schema, FindTablets is used to select tablets for that keyspace; if the lookup fails for any reason the code (arguably over-broadly) wraps errors.ErrNoTablet with the keyspace name. It signals that no tablets could be resolved for the keyspace, so schema cannot be fetched.

Source

Thrown at go/vt/vtadmin/cluster/cluster.go:1434

	}
	if !opts.isBackfill && !cache.ShouldRefreshFromIncomingContext(ctx) {
		schema, ok, err := schemacache.LoadOne(c.schemaCache, key, schemacache.LoadOptions{
			BaseRequest:    opts.BaseRequest,
			AggregateSizes: opts.TableSizeOptions.AggregateSizes,
		})

		span.Annotate("cache_hit", ok)
		if ok {
			return schema, err
		}
	}

	// Fetch all tablets for the keyspace.
	tablets, err := c.FindTablets(ctx, func(tablet *vtadminpb.Tablet) bool {
		return tablet.Tablet.Keyspace == keyspace
	}, -1)
	if err != nil {
		return nil, fmt.Errorf("%w for keyspace %s", errors.ErrNoTablet, keyspace)
	}

	tabletsToQuery, err := c.getTabletsToQueryForSchemas(ctx, keyspace, tablets, opts)
	if err != nil {
		return nil, err
	}

	schema, err := c.getSchemaFromTablets(ctx, keyspace, tabletsToQuery, opts)
	if err != nil {
		return nil, err
	}

	go schemacache.AddOrBackfill(c.schemaCache, []*vtadminpb.Schema{schema}, key, c.cfg.SchemaCacheConfig.DefaultExpiration, schemacache.LoadOptions{
		BaseRequest:    opts.BaseRequest,
		AggregateSizes: opts.TableSizeOptions.AggregateSizes,
	})

	return schema, nil

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the keyspace name is correct and exists (list keyspaces via vtctld)
  2. Confirm tablets exist and are registered in the topo for that keyspace
  3. Check the underlying FindTablets/topo error — a topo failure is masked as ErrNoTablet here
  4. If the keyspace is intentionally empty, treat 'no tablet' as expected and skip schema fetch
Defensive patterns

Strategy: validation

Validate before calling

// Go: confirm the keyspace exists before fetching its schema
resp, err := vtctldClient.GetKeyspace(ctx, &vtctldatapb.GetKeyspaceRequest{Keyspace: name})
if err != nil {
	return fmt.Errorf("keyspace %s does not exist: %w", name, err)
}

Type guard

func isNoTablet(err error) bool {
	return errors.Is(err, errors.ErrNoTablet)
}

Try / catch

schema, err := c.GetSchema(ctx, req)
if err != nil {
	if isNoTablet(err) {
		// verify keyspace name; treat empty keyspace as empty schema
	}
	return err
}

Prevention

When it happens

Trigger: Calling GetSchema (keyspace-scoped) for a keyspace with zero tablets, a misspelled/nonexistent keyspace, or when FindTablets itself errors (topo failure) — all surface as 'ErrNoTablet for keyspace X'.

Common situations: Typo'd keyspace name in an API request; keyspace recently created but tablets not yet registered; keyspace drained/deleted while schema was being fetched; topo connectivity problems mistaken for 'no tablets'.

Related errors


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