vitessio/vitess · error

GetShardNames(%v): %w

Error message

GetShardNames(%v): %w

What it means

CopyShards wraps errors from fromTS.GetShardNames(ctx, keyspace) with the failing keyspace name. The keyspace list was read, but enumerating the shards under one keyspace failed. No destination mutation happens for that keyspace; the copy aborts.

Source

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

		default:
			log.Error(fmt.Sprintf("GetVSchema(%v): %v", keyspace, err))
		}
	}

	return nil
}

// CopyShards will create the shards in the destination topo.
func CopyShards(ctx context.Context, fromTS, toTS *topo.Server) error {
	keyspaces, err := fromTS.GetKeyspaces(ctx)
	if err != nil {
		return fmt.Errorf("fromTS.GetKeyspaces: %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 {
			si, err := fromTS.GetShard(ctx, keyspace, shard)
			if err != nil {
				return fmt.Errorf("GetShard(%v, %v): %w", keyspace, shard, err)
			}

			if err := toTS.CreateShard(ctx, keyspace, shard); err != nil {
				if topo.IsErrType(err, topo.NodeExists) {
					log.Warn(fmt.Sprintf("shard %v/%v already exists", keyspace, shard))
				} else {
					return fmt.Errorf("CreateShard(%v, %v): %w", keyspace, shard, err)
				}
			}
			if _, err := toTS.UpdateShardFields(ctx, keyspace, shard, func(toSI *topo.ShardInfo) error {
				toSI.Shard = si.CloneVT()
				return nil

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. If the wrapped cause is topo.NoNode, re-run after the concurrent keyspace deletion completes; consider skipping vanished keyspaces.
  2. Retry the copy — it is idempotent for already-created shards (NodeExists is warned).
  3. Check source topo backend logs for the specific keyspace path errors.
  4. Verify the keyspace's shard directory is intact in the topo backend.

Example fix

// before
shards, err := fromTS.GetShardNames(ctx, keyspace)
if err != nil {
	return fmt.Errorf("GetShardNames(%v): %w", keyspace, err)
}
// after
shards, err := fromTS.GetShardNames(ctx, keyspace)
if err != nil {
	if topo.IsErrType(err, topo.NoNode) {
		log.Warn(fmt.Sprintf("keyspace %v gone, skipping", keyspace))
		continue
	}
	return fmt.Errorf("GetShardNames(%v): %w", keyspace, err)
}
Defensive patterns

Strategy: type-guard

Validate before calling

shards, err := fromTS.GetShardNames(ctx, ks)
if err != nil && topo.IsErrType(err, topo.NoNode) {
	// keyspace disappeared; re-run listing
}

Type guard

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

Try / catch

shards, err := fromTS.GetShardNames(ctx, keyspace)
if err != nil {
	if topo.IsErrType(err, topo.NoNode) {
		continue
	}
	return fmt.Errorf("GetShardNames(%v): %w", keyspace, err)
}

Prevention

When it happens

Trigger: Calling CopyShards when GetShardNames returns topo.NoNode (keyspace deleted concurrently between list and shard-listing), a source topo connection failure, or a corrupted keyspace node.

Common situations: Race with a concurrent DeleteKeyspace or reshard teardown; etcd compaction removing revision data; intermittent topo connection resets during large copies.

Related errors


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