vitessio/vitess · error

query %#v returned %d columns, expected 2

Error message

query %#v returned %d columns, expected 2

What it means

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.

Source

Thrown at go/vt/mysqlctl/query.go:293

		killConn.Close()
		return killErr
	case <-ctx.Done():
		killConn.Close()
		<-done
		return ctx.Err()
	}
}

// fetchVariables returns a map from MySQL variable names to variable value
// for variables that match the given pattern.
func (mysqld *Mysqld) fetchVariables(ctx context.Context, pattern string) (map[string]string, error) {
	query := fmt.Sprintf("SHOW VARIABLES LIKE '%s'", pattern)
	qr, err := mysqld.FetchSuperQuery(ctx, query)
	if err != nil {
		return nil, err
	}
	if len(qr.Fields) != 2 {
		return nil, fmt.Errorf("query %#v returned %d columns, expected 2", query, len(qr.Fields))
	}
	varMap := make(map[string]string, len(qr.Rows))
	for _, row := range qr.Rows {
		varMap[row[0].ToString()] = row[1].ToString()
	}
	return varMap, nil
}

// fetchStatuses returns a map from MySQL status names to status value
// for variables that match the given pattern.
func (mysqld *Mysqld) fetchStatuses(ctx context.Context, pattern string) (map[string]string, error) {
	query := fmt.Sprintf("SHOW STATUS LIKE '%s'", pattern)
	qr, err := mysqld.FetchSuperQuery(ctx, query)
	if err != nil {
		return nil, err
	}
	if len(qr.Fields) != 2 {
		return nil, fmt.Errorf("query %#v returned %d columns, expected 2", query, len(qr.Fields))

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the tablet connects directly to mysqld, not through a proxy rewriting result metadata
  2. Log/capture the full query (`SHOW VARIABLES LIKE '<pattern>'`) from the error message and run it manually to inspect the result shape
  3. Check the wrapped FetchSuperQuery path and any custom hooks for result post-processing
Defensive patterns

Strategy: try-catch

Validate before calling

qr, err := mysqld.FetchSuperQuery(ctx, "SHOW VARIABLES LIKE 'rpl_semi_sync%'")
if err == nil && len(qr.Fields) != 2 {
    log.Warn("non-standard SHOW VARIABLES result shape; check for proxies/interceptors")
}

Try / catch

enabled, err := mysqld.SemiSyncEnabled(ctx)
if err != nil {
    if strings.Contains(err.Error(), "returned") && strings.Contains(err.Error(), "columns, expected 2") {
        // inspect proxy/interceptor rewriting SHOW VARIABLES results
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/3552e7e622b3799a. Report an issue: GitHub.