vitessio/vitess · error

GetTabletMapForShard(%s, %s) failed: %w

Error message

GetTabletMapForShard(%s, %s) failed: %w

What it means

Returned by the grpcvtctldserver when fetching the tablet map for a shard from the topology fails, wrapping the topo error with the keyspace and shard being queried.

Source

Thrown at go/vt/vtctl/grpcvtctldserver/server.go:2332

	ctx, cancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)
	defer cancel()

	var tabletMap map[string]*topo.TabletInfo

	switch {
	case len(req.TabletAliases) > 0:
		span.Annotate("tablet_aliases", strings.Join(topoproto.TabletAliasList(req.TabletAliases).ToStringSlice(), ","))

		tabletMap, err = s.ts.GetTabletMap(ctx, req.TabletAliases, nil)
		if err != nil {
			err = fmt.Errorf("GetTabletMap(%v) failed: %w", req.TabletAliases, err)
		}
	case req.Keyspace != "" && req.Shard != "":
		span.Annotate("shard", req.Shard)

		tabletMap, err = s.ts.GetTabletMapForShard(ctx, req.Keyspace, req.Shard)
		if err != nil {
			err = fmt.Errorf("GetTabletMapForShard(%s, %s) failed: %w", req.Keyspace, req.Shard, err)
		}
	default:
		// goto the req.Cells branch
		tabletMap = nil
	}

	if err != nil {
		switch {
		case topo.IsErrType(err, topo.PartialResult):
			if req.Strict {
				return nil, err
			}
			log.Warn(fmt.Sprintf("GetTablets encountered non-fatal error %s; continuing because Strict=false", err))
		default:
			return nil, err
		}
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the keyspace and shard names are correct and the shard record exists in the topo.
  2. Check topo server health and connectivity from vtctld.
  3. Retry after transient topo failures.

Example fix

// before
vtctldclient GetTablets --keyspace commerce --shard "0-"
// after
vtctldclient GetTablets --keyspace commerce --shard "-"
Defensive patterns

Strategy: validation

Validate before calling

if _, err := s.ts.GetShard(ctx, req.Keyspace, req.Shard); err != nil {
    return fmt.Errorf("shard %s/%s not found: %w", req.Keyspace, req.Shard, err)
}

Try / catch

tabletMap, err := s.ts.GetTabletMapForShard(ctx, req.Keyspace, req.Shard)
if err != nil {
    return fmt.Errorf("GetTabletMapForShard(%s, %s) failed: %w", req.Keyspace, req.Shard, err)
}

Prevention

When it happens

Trigger: Calling GetTablets with req.Keyspace and req.Shard set when the shard record is missing, unreadable, or the topo store call fails.

Common situations: Typo in keyspace/shard name, shard not yet created in the topo, or topo store outage during scripted operations.

Related errors


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