{"record":{"id":"835c60716e8da4d6","repo":"vitessio/vitess","slug":"getschema-s-w","errorCode":null,"errorMessage":"GetSchema(%s): %w","messagePattern":"GetSchema\\((.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/api.go","lineNumber":2733,"sourceCode":"\t\t// Writes to these three variables are, in the strictest sense, unsafe.\n\t\t// However, there is one goroutine responsible for writing each of these\n\t\t// values (so, no concurrent writes), and reads are blocked on the call to\n\t\t// wg.Wait(), so we guarantee that all writes have finished before attempting\n\t\t// to read anything.\n\t\tsrvVSchema string\n\t\tschema     string\n\t\tshardMap   string\n\t)\n\n\twg.Add(3)\n\n\t// GetSchema\n\tgo func(c *cluster.Cluster) {\n\t\tdefer wg.Done()\n\n\t\tres, err := c.GetSchema(ctx, req.Keyspace, cluster.GetSchemaOptions{})\n\t\tif err != nil {\n\t\t\ter.RecordError(fmt.Errorf(\"GetSchema(%s): %w\", topoproto.TabletAliasString(tablet.Tablet.Alias), err))\n\t\t\treturn\n\t\t}\n\n\t\tschemas := make([]string, len(res.TableDefinitions))\n\t\tfor i, td := range res.TableDefinitions {\n\t\t\tschemas[i] = td.Schema\n\t\t}\n\n\t\tschema = strings.Join(schemas, \";\")\n\t}(c)\n\n\t// GetSrvVSchema\n\tgo func(c *cluster.Cluster) {\n\t\tdefer wg.Done()\n\n\t\tspan, ctx := trace.NewSpan(ctx, \"Cluster.GetSrvVSchema\")\n\t\tdefer span.Finish()\n","sourceCodeStart":2715,"sourceCodeEnd":2751,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/api.go#L2715-L2751","documentation":"During VTEXplain, VTAdmin concurrently fetches the keyspace schema from the chosen tablet via cluster.GetSchema. If that call fails, the error is recorded into the request's ErrorRecorder, annotated with the tablet alias, and the goroutine returns; the overall vtexplain will subsequently fail or produce a partial result. It indicates the schema could not be read from that tablet.","triggerScenarios":"The GetSchema goroutine's c.GetSchema(ctx, keyspace, opts) returns an error — underlying vtctld/tablet RPC failure, tablet died mid-request, timeout, or the tablet rejected the schema query.","commonSituations":"Tablet becomes unhealthy between selection and schema fetch; network partition between vtadmin and vttablet/vtctld; RPC deadline exceeded under load; mysqld issue preventing SHOW CREATE TABLE.","solutions":["Retry the VTEXplain request; transient tablet errors often resolve once the tablet re-registers as healthy.","Check the health of the tablet named in the error (`vtctldclient GetTablet <alias>`) and restart/replace it if unhealthy.","Verify network connectivity and RPC timeouts between vtadmin, vtctld, and vttablet.","Check vttablet logs for the underlying GetSchema failure (mysqld errors, permission issues).","If persistent, ensure the keyspace has multiple serving replicas so a healthy one can serve the schema."],"exampleFix":"// before\nres, err := c.GetSchema(ctx, req.Keyspace, cluster.GetSchemaOptions{})\nif err != nil { er.RecordError(...); return }\n// after (mitigation at caller level: retry)\nvar res *vtadminpb.Schema\nfor i := 0; i < 3; i++ {\n    res, err = c.GetSchema(ctx, req.Keyspace, cluster.GetSchemaOptions{})\n    if err == nil { break }\n    time.Sleep(time.Second)\n}","handlingStrategy":"retry","validationCode":"// Check tablet health first\n_, err := apiClient.GetTablet(ctx, alias)\nif err != nil { return fmt.Errorf(\"tablet %s unhealthy before vtexplain: %w\", alias, err) }","typeGuard":null,"tryCatchPattern":"errGroup, ctx := errgroup.WithContext(ctx)\nerrGroup.Go(func() error {\n    res, err := c.GetSchema(ctx, req.Keyspace, cluster.GetSchemaOptions{})\n    if err != nil {\n        if isTransient(err) { return retryWithBackoff(...) }\n        return fmt.Errorf(\"GetSchema(%s): %w\", alias, err)\n    }\n    return nil\n})\nif err := errGroup.Wait(); err != nil { return err }","preventionTips":["Keep at least two serving replicas per keyspace so schema fetch has redundancy.","Set generous but bounded RPC timeouts for vtadmin->tablet calls.","Monitor vttablet health so failing tablets are detected before vtexplain runs."],"tags":["vtadmin","vtexplain","schema","rpc-failure"],"backgroundTag":"schema-fetch-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}