{"record":{"id":"cb381539c4b74596","repo":"vitessio/vitess","slug":"getkeyspaces-w","errorCode":null,"errorMessage":"GetKeyspaces: %w","messagePattern":"GetKeyspaces: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/topo/helpers/copy.go","lineNumber":40,"sourceCode":"\t\"context\"\n\t\"fmt\"\n\n\t\"google.golang.org/protobuf/proto\"\n\n\t\"vitess.io/vitess/go/vt/log\"\n\t\"vitess.io/vitess/go/vt/sqlparser\"\n\t\"vitess.io/vitess/go/vt/topo\"\n\t\"vitess.io/vitess/go/vt/topo/topoproto\"\n\t\"vitess.io/vitess/go/vt/vtgate/vindexes\"\n\n\ttopodatapb \"vitess.io/vitess/go/vt/proto/topodata\"\n)\n\n// CopyKeyspaces will create the keyspaces in the destination topo.\nfunc CopyKeyspaces(ctx context.Context, fromTS, toTS *topo.Server, parser *sqlparser.Parser) error {\n\tkeyspaces, err := fromTS.GetKeyspaces(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"GetKeyspaces: %w\", err)\n\t}\n\n\tfor _, keyspace := range keyspaces {\n\t\tki, err := fromTS.GetKeyspace(ctx, keyspace)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"GetKeyspace(%v): %w\", keyspace, err)\n\t\t}\n\n\t\tif err := toTS.CreateKeyspace(ctx, keyspace, ki.Keyspace); err != nil {\n\t\t\tif topo.IsErrType(err, topo.NodeExists) {\n\t\t\t\tlog.Warn(fmt.Sprintf(\"keyspace %v already exists\", keyspace))\n\t\t\t} else {\n\t\t\t\tlog.Error(fmt.Sprintf(\"CreateKeyspace(%v): %v\", keyspace, err))\n\t\t\t}\n\t\t}\n\n\t\tksvs, err := fromTS.GetVSchema(ctx, keyspace)\n\t\tswitch {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/topo/helpers/copy.go#L22-L58","documentation":"CopyKeyspaces wraps errors from fromTS.GetKeyspaces(ctx) with the 'GetKeyspaces: ' prefix. This function copies all keyspace records from a source topo server to a destination topo server. The wrapped error means the source topology could not be read at all (the listing RPC failed), so the copy aborts before touching the destination.","triggerScenarios":"Calling topo/helpers.CopyKeyspaces(ctx, fromTS, toTS, parser) when fromTS.GetKeyspaces fails: source topo server unreachable, connection refused, context canceled/expired mid-list, or the global cell is corrupted or unavailable.","commonSituations":"Wrong vtctld/topo endpoint or port in config during topo-to-topo migrations; source etcd/zk cluster down or misconfigured; firewall blocking the topo port; context deadline too short on slow topo backends; network partitions during cluster-to-cluster copy tooling.","solutions":["Verify the source topo server (fromTS) is reachable: check topo flags/config (--topo_implementation, --topo_server, --topo_etcd_server etc.) and test connectivity.","Increase the context timeout / retry the copy if the deadline was exceeded.","Check the source topo backend (etcd/zk/k8s) health and logs for the root cause included in the wrapped error.","Inspect fromTS connection credentials/ACLs for read access to the keyspaces path."],"exampleFix":"// before\nkeyspaces, err := fromTS.GetKeyspaces(ctx)\nif err != nil {\n\treturn fmt.Errorf(\"GetKeyspaces: %w\", err)\n}\n// after (caller-side retry)\nvar keyspaces []string\nerr := retry.Do(func() error {\n\tvar e error\n\tkeyspaces, e = fromTS.GetKeyspaces(ctx)\n\treturn e\n}, retry.Attempts(3), retry.Delay(time.Second))\nif err != nil {\n\treturn fmt.Errorf(\"GetKeyspaces: %w\", err)\n}","handlingStrategy":"retry","validationCode":"if _, err := fromTS.GetKeyspaces(ctx); err != nil {\n\treturn fmt.Errorf(\"source topo unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"keyspaces, err := fromTS.GetKeyspaces(ctx)\nif err != nil {\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\treturn fmt.Errorf(\"GetKeyspaces: %w\", err)\n}","preventionTips":["Pre-flight check source topo connectivity with a cheap GetKeyspaces or GetKnownCells call before copying.","Use a context with a generous but bounded deadline for topo operations.","Monitor the source topo backend (etcd/zk) health before starting topo migrations.","Pin topo server addresses in config and validate them at startup."],"tags":["go","topo","etcd","network"],"backgroundTag":"topo-server-unreachable","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}