{"record":{"id":"cbb0a4c272f5fdba","repo":"vitessio/vitess","slug":"getshardnames-v-w","errorCode":null,"errorMessage":"GetShardNames(%v): %w","messagePattern":"GetShardNames\\((.+?)\\): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/helpers/copy.go","lineNumber":88,"sourceCode":"\t\tdefault:\n\t\t\tlog.Error(fmt.Sprintf(\"GetVSchema(%v): %v\", keyspace, err))\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// CopyShards will create the shards in the destination topo.\nfunc CopyShards(ctx context.Context, fromTS, toTS *topo.Server) error {\n\tkeyspaces, err := fromTS.GetKeyspaces(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"fromTS.GetKeyspaces: %w\", err)\n\t}\n\n\tfor _, keyspace := range keyspaces {\n\t\tshards, err := fromTS.GetShardNames(ctx, keyspace)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"GetShardNames(%v): %w\", keyspace, err)\n\t\t}\n\n\t\tfor _, shard := range shards {\n\t\t\tsi, err := fromTS.GetShard(ctx, keyspace, shard)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"GetShard(%v, %v): %w\", keyspace, shard, err)\n\t\t\t}\n\n\t\t\tif err := toTS.CreateShard(ctx, keyspace, shard); err != nil {\n\t\t\t\tif topo.IsErrType(err, topo.NodeExists) {\n\t\t\t\t\tlog.Warn(fmt.Sprintf(\"shard %v/%v already exists\", keyspace, shard))\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"CreateShard(%v, %v): %w\", keyspace, shard, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif _, err := toTS.UpdateShardFields(ctx, keyspace, shard, func(toSI *topo.ShardInfo) error {\n\t\t\t\ttoSI.Shard = si.CloneVT()\n\t\t\t\treturn nil","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/helpers/copy.go#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"Race with a concurrent DeleteKeyspace or reshard teardown; etcd compaction removing revision data; intermittent topo connection resets during large copies.","solutions":["If the wrapped cause is topo.NoNode, re-run after the concurrent keyspace deletion completes; consider skipping vanished keyspaces.","Retry the copy — it is idempotent for already-created shards (NodeExists is warned).","Check source topo backend logs for the specific keyspace path errors.","Verify the keyspace's shard directory is intact in the topo backend."],"exampleFix":"// before\nshards, err := fromTS.GetShardNames(ctx, keyspace)\nif err != nil {\n\treturn fmt.Errorf(\"GetShardNames(%v): %w\", keyspace, err)\n}\n// after\nshards, err := fromTS.GetShardNames(ctx, keyspace)\nif err != nil {\n\tif topo.IsErrType(err, topo.NoNode) {\n\t\tlog.Warn(fmt.Sprintf(\"keyspace %v gone, skipping\", keyspace))\n\t\tcontinue\n\t}\n\treturn fmt.Errorf(\"GetShardNames(%v): %w\", keyspace, err)\n}","handlingStrategy":"type-guard","validationCode":"shards, err := fromTS.GetShardNames(ctx, ks)\nif err != nil && topo.IsErrType(err, topo.NoNode) {\n\t// keyspace disappeared; re-run listing\n}","typeGuard":"func keyspaceVanished(err error) bool {\n\treturn topo.IsErrType(err, topo.NoNode)\n}","tryCatchPattern":"shards, err := fromTS.GetShardNames(ctx, keyspace)\nif err != nil {\n\tif topo.IsErrType(err, topo.NoNode) {\n\t\tcontinue\n\t}\n\treturn fmt.Errorf(\"GetShardNames(%v): %w\", keyspace, err)\n}","preventionTips":["Quiesce keyspace lifecycle operations during topo copies.","Retry the idempotent copy rather than treating races as fatal.","Log and skip NoNode races instead of aborting the whole copy."],"tags":["go","topo","race-condition"],"backgroundTag":"topo-node-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}