{"record":{"id":"3552e7e622b3799a","repo":"vitessio/vitess","slug":"query-v-returned-d-columns-expected-2","errorCode":null,"errorMessage":"query %#v returned %d columns, expected 2","messagePattern":"query %#v returned (.+?) columns, expected 2","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/query.go","lineNumber":293,"sourceCode":"\t\tkillConn.Close()\n\t\treturn killErr\n\tcase <-ctx.Done():\n\t\tkillConn.Close()\n\t\t<-done\n\t\treturn ctx.Err()\n\t}\n}\n\n// fetchVariables returns a map from MySQL variable names to variable value\n// for variables that match the given pattern.\nfunc (mysqld *Mysqld) fetchVariables(ctx context.Context, pattern string) (map[string]string, error) {\n\tquery := fmt.Sprintf(\"SHOW VARIABLES LIKE '%s'\", pattern)\n\tqr, err := mysqld.FetchSuperQuery(ctx, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(qr.Fields) != 2 {\n\t\treturn nil, fmt.Errorf(\"query %#v returned %d columns, expected 2\", query, len(qr.Fields))\n\t}\n\tvarMap := make(map[string]string, len(qr.Rows))\n\tfor _, row := range qr.Rows {\n\t\tvarMap[row[0].ToString()] = row[1].ToString()\n\t}\n\treturn varMap, nil\n}\n\n// fetchStatuses returns a map from MySQL status names to status value\n// for variables that match the given pattern.\nfunc (mysqld *Mysqld) fetchStatuses(ctx context.Context, pattern string) (map[string]string, error) {\n\tquery := fmt.Sprintf(\"SHOW STATUS LIKE '%s'\", pattern)\n\tqr, err := mysqld.FetchSuperQuery(ctx, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(qr.Fields) != 2 {\n\t\treturn nil, fmt.Errorf(\"query %#v returned %d columns, expected 2\", query, len(qr.Fields))","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/query.go#L275-L311","documentation":"fetchVariables runs `SHOW VARIABLES LIKE '<pattern>'` and expects the standard two-column result (Variable_name, Value). This error reports that the result had a different column count, so the variable map cannot be built reliably.","triggerScenarios":"Called from SemiSyncEnabled (and other variable lookups) when mysqld.FetchSuperQuery returns a query result whose Fields length is not 2 — essentially only possible with a non-standard/proxied MySQL endpoint or corrupted result.","commonSituations":"Connecting through a proxy or shim that rewrites SHOW VARIABLES results; custom build/interceptor altering result metadata; extremely unlikely with real MySQL servers since SHOW VARIABLES always returns two columns.","solutions":["Verify the tablet connects directly to mysqld, not through a proxy rewriting result metadata","Log/capture the full query (`SHOW VARIABLES LIKE '<pattern>'`) from the error message and run it manually to inspect the result shape","Check the wrapped FetchSuperQuery path and any custom hooks for result post-processing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"qr, err := mysqld.FetchSuperQuery(ctx, \"SHOW VARIABLES LIKE 'rpl_semi_sync%'\")\nif err == nil && len(qr.Fields) != 2 {\n    log.Warn(\"non-standard SHOW VARIABLES result shape; check for proxies/interceptors\")\n}","typeGuard":null,"tryCatchPattern":"enabled, err := mysqld.SemiSyncEnabled(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"returned\") && strings.Contains(err.Error(), \"columns, expected 2\") {\n        // inspect proxy/interceptor rewriting SHOW VARIABLES results\n    }\n}","preventionTips":["Connect tablets directly to mysqld rather than through result-rewriting proxies","Avoid custom builds/interceptors that alter SHOW statement metadata","Verify SHOW VARIABLES returns the standard (Variable_name, Value) pair during environment setup"],"tags":["mysql","query-result","semisync"],"backgroundTag":"unexpected-result-column-count","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}