{"record":{"id":"a27acc232e0007fe","repo":"vitessio/vitess","slug":"getshard-v-v-w","errorCode":null,"errorMessage":"GetShard(%v, %v): %w","messagePattern":"GetShard\\((.+?), (.+?)\\): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/helpers/copy.go","lineNumber":94,"sourceCode":"}\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\n\t\t\t}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"UpdateShardFields(%v, %v): %w\", keyspace, shard, err)\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/helpers/copy.go#L76-L112","documentation":"CopyShards wraps errors from fromTS.GetShard(ctx, keyspace, shard) with the keyspace and shard names. Shard names were listed successfully but reading the individual Shard record from the source topo failed, aborting the copy before any destination write.","triggerScenarios":"Calling CopyShards when GetShard returns a connection error, NoNode (shard removed concurrently), or unmarshal failure on a corrupt shard record.","commonSituations":"Concurrent shard teardown/pruning while copying; etcd/zk instability mid-scan; partially deleted shard directories left by earlier failed operations.","solutions":["Identify the exact keyspace/shard from the message and check its node in the source topo backend directly.","If NoNode, re-run after concurrent shard operations settle, or skip the missing shard.","Retry the copy; destination-side steps are idempotent (NodeExists tolerated).","Repair or remove corrupt shard records in the source topo if unmarshaling fails."],"exampleFix":"// before\nsi, err := fromTS.GetShard(ctx, keyspace, shard)\nif err != nil {\n\treturn fmt.Errorf(\"GetShard(%v, %v): %w\", keyspace, shard, err)\n}\n// after\nsi, err := fromTS.GetShard(ctx, keyspace, shard)\nif err != nil {\n\tif topo.IsErrType(err, topo.NoNode) {\n\t\tlog.Warn(fmt.Sprintf(\"shard %v/%v gone, skipping\", keyspace, shard))\n\t\tcontinue\n\t}\n\treturn fmt.Errorf(\"GetShard(%v, %v): %w\", keyspace, shard, err)\n}","handlingStrategy":"type-guard","validationCode":"_, err := fromTS.GetShard(ctx, ks, shard)\nif err != nil && topo.IsErrType(err, topo.NoNode) {\n\t// shard record missing; skip or repair\n}","typeGuard":"func shardMissing(err error) bool {\n\treturn topo.IsErrType(err, topo.NoNode)\n}","tryCatchPattern":"si, err := fromTS.GetShard(ctx, keyspace, shard)\nif err != nil {\n\tif topo.IsErrType(err, topo.NoNode) {\n\t\tcontinue\n\t}\n\treturn fmt.Errorf(\"GetShard(%v, %v): %w\", keyspace, shard, err)\n}","preventionTips":["Check for leftover partially-deleted shard records before copying.","Quiesce shard teardown/pruning operations during the copy.","Validate shard records parse cleanly with a dry-run GetShard scan."],"tags":["go","topo"],"backgroundTag":"topo-node-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}