vitessio/vitess · error

GetShardReplication(%v, %v, %v): %w

Error message

GetShardReplication(%v, %v, %v): %w

What it means

CopyShardReplications reads each ShardReplication object from the source topo per (cell, keyspace, shard) with fromTS.GetShardReplication. This error wraps that read failure and identifies the exact cell/keyspace/shard triple.

Source

Thrown at go/vt/topo/helpers/copy.go:178

		return fmt.Errorf("fromTS.GetKeyspaces: %w", err)
	}

	cells, err := fromTS.GetCellInfoNames(ctx)
	if err != nil {
		return fmt.Errorf("GetCellInfoNames(): %w", err)
	}

	for _, keyspace := range keyspaces {
		shards, err := fromTS.GetShardNames(ctx, keyspace)
		if err != nil {
			return fmt.Errorf("GetShardNames(%v): %w", keyspace, err)
		}

		for _, shard := range shards {
			for _, cell := range cells {
				sri, err := fromTS.GetShardReplication(ctx, cell, keyspace, shard)
				if err != nil {
					return fmt.Errorf("GetShardReplication(%v, %v, %v): %w", cell, keyspace, shard, err)
				}

				sriNodes := map[string]struct{}{}
				for _, node := range sri.Nodes {
					sriNodes[topoproto.TabletAliasString(node.TabletAlias)] = struct{}{}
				}

				if err := toTS.UpdateShardReplicationFields(ctx, cell, keyspace, shard, func(oldSR *topodatapb.ShardReplication) error {
					var nodes []*topodatapb.ShardReplication_Node
					for _, oldNode := range oldSR.Nodes {
						if _, ok := sriNodes[topoproto.TabletAliasString(oldNode.TabletAlias)]; ok {
							continue
						}

						nodes = append(nodes, oldNode)
					}

					nodes = append(nodes, sri.Nodes...)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check whether the ShardReplication node legitimately should exist for that cell/keyspace/shard; skip or create it as appropriate
  2. Ignore expected topo.NoNode cases if the copy tolerates missing replication records
  3. Verify source topo health and retry the copy
  4. Rebuild the ShardReplication record in the source (e.g. via tablet repair / RefreshState)

Example fix

// before
sri, err := fromTS.GetShardReplication(ctx, cell, keyspace, shard)
if err != nil {
    return fmt.Errorf("GetShardReplication(%v, %v, %v): %w", cell, keyspace, shard, err)
}
// after
sri, err := fromTS.GetShardReplication(ctx, cell, keyspace, shard)
if topo.IsErrType(err, topo.NoNode) {
    continue // no replication record in this cell
} else if err != nil {
    return fmt.Errorf("GetShardReplication(%v, %v, %v): %w", cell, keyspace, shard, err)
}
Defensive patterns

Strategy: type-guard

Validate before calling

_, err := fromTS.GetShardReplication(ctx, cell, keyspace, shard)
if topo.IsErrType(err, topo.NoNode) {
    log.Warnf("no ShardReplication node in cell %s", cell)
}

Type guard

func isNoNode(err error) bool { return topo.IsErrType(err, topo.NoNode) }

Try / catch

err := helpers.CopyShardReplications(ctx, fromTS, toTS)
var missing topo.ErrNoNode
if err != nil && strings.Contains(err.Error(), "GetShardReplication") {
    log.Errorf("shard replication node missing: %v", err)
} else if err != nil {
    return err
}

Prevention

When it happens

Trigger: Calling CopyShardReplications when fromTS.GetShardReplication fails: the ShardReplication node does not exist in that cell, ctx cancellation, or a source topo backend error.

Common situations: A shard exists but its ShardReplication node was never created in some cell (e.g. tablet placed without replication record); concurrent topo surgery; transient backend timeouts.

Related errors


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