{"record":{"id":"a0eba37230ed2f5c","repo":"vitessio/vitess","slug":"createshard-v-v-w","errorCode":null,"errorMessage":"CreateShard(%v, %v): %w","messagePattern":"CreateShard\\((.+?), (.+?)\\): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/helpers/copy.go","lineNumber":101,"sourceCode":"\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\n\treturn nil\n}\n\n// CopyTablets will create the tablets in the destination topo.\nfunc CopyTablets(ctx context.Context, fromTS, toTS *topo.Server) error {\n\tcells, err := fromTS.GetKnownCells(ctx)\n\tif err != nil {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/helpers/copy.go#L83-L119","documentation":"CopyShards wraps errors from toTS.CreateShard(ctx, keyspace, shard) with the keyspace and shard names. This is the first destination-side write: NodeExists on the destination is expected and downgraded to a warning; any other error (connection failure, permission, timeout) aborts the copy.","triggerScenarios":"Calling CopyShards when the destination topo rejects CreateShard for reasons other than NodeExists: destination topo unreachable, write ACL denied, or context canceled during the create RPC.","commonSituations":"Destination etcd/zk cluster read-only (e.g. etcd in maintenance, zk read-only mode); missing write credentials in destination topo config; network partition to the destination cluster mid-copy.","solutions":["Check destination topo (toTS) connectivity and that the backend accepts writes.","Verify write ACLs/credentials for the destination topo user.","If the error is an unexpected non-NodeExists conflict, inspect the destination shard node and reconcile manually.","Retry the copy after fixing the destination; existing shards are skipped safely."],"exampleFix":"// before\nif err := toTS.CreateShard(ctx, keyspace, shard); err != nil {\n\tif topo.IsErrType(err, topo.NodeExists) {\n\t\tlog.Warn(fmt.Sprintf(\"shard %v/%v already exists\", keyspace, shard))\n\t} else {\n\t\treturn fmt.Errorf(\"CreateShard(%v, %v): %w\", keyspace, shard, err)\n\t}\n}\n// after (caller verifies destination is writable first)\nerr := toTS.CreateKeyspace(ctx, probeKs, &topodatapb.Keyspace{})\nif err != nil && !topo.IsErrType(err, topo.NodeExists) {\n\treturn fmt.Errorf(\"destination topo not writable: %w\", err)\n}\n_ = toTS.DeleteKeyspace(ctx, probeKs)","handlingStrategy":"validation","validationCode":"err := toTS.CreateKeyspace(ctx, probeKs, &topodatapb.Keyspace{})\nwritable := err == nil || topo.IsErrType(err, topo.NodeExists)\nif err == nil {\n\t_ = toTS.DeleteKeyspace(ctx, probeKs)\n}\n_ = writable","typeGuard":null,"tryCatchPattern":"if err := toTS.CreateShard(ctx, keyspace, shard); err != nil && !topo.IsErrType(err, topo.NodeExists) {\n\tif topo.IsErrType(err, topo.PermissionDenied) {\n\t\treturn fmt.Errorf(\"fix destination topo write ACLs: %w\", err)\n\t}\n\treturn fmt.Errorf(\"CreateShard(%v, %v): %w\", keyspace, shard, err)\n}","preventionTips":["Verify destination topo write credentials and ACLs before copying.","Ensure destination etcd/zk is not in read-only/maintenance mode.","Run a small probe write against the destination before batch copies."],"tags":["go","topo","permissions"],"backgroundTag":"topo-write-denied","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}