vitessio/vitess · warning

failed setting value for %v: %v

Error message

failed setting value for %v: %v

What it means

For context-aware integer variables on the debug env endpoint (ReadPoolSize, StreamPoolSize, TransactionPoolSize), setIntValCtx first parses the value with strconv.Atoi and then calls the setter (e.g. SetPoolSize) with the request context; this error wraps either the parse failure or the setter's own failure (e.g. refusing to resize a pool below what is in use). It is returned to the client as HTTP 400.

Source

Thrown at go/vt/vttablet/tabletserver/debugenv.go:110

	}

	setIntVal := func(f func(int)) error {
		ival, err := strconv.Atoi(value)
		if err != nil {
			return fmt.Errorf("invalid int value for %v: %v", varname, err)
		}
		f(ival)
		msg = fmt.Sprintf("Setting %v to: %v", varname, value)
		return nil
	}

	setIntValCtx := func(f func(context.Context, int) error) error {
		ival, err := strconv.Atoi(value)
		if err == nil {
			err = f(r.Context(), ival)
		}
		if err != nil {
			return fmt.Errorf("failed setting value for %v: %v", varname, err)
		}
		msg = fmt.Sprintf("Setting %v to: %v", varname, value)
		return nil
	}

	setInt64Val := func(f func(int64)) error {
		ival, err := strconv.ParseInt(value, 10, 64)
		if err != nil {
			return fmt.Errorf("invalid int64 value for %v: %v", varname, err)
		}
		f(ival)
		msg = fmt.Sprintf("Setting %v to: %v", varname, value)
		return nil
	}

	setDurationVal := func(f func(time.Duration)) error {
		durationVal, err := time.ParseDuration(value)
		if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the value is a plain base-10 integer (no units, commas, or spaces)
  2. If the value parsed but the setter failed, read the wrapped inner error: e.g. pick a pool size >= current in-use connections
  3. Retry the POST with the client connection kept open until the response arrives
  4. Check tabletserver logs around the request for the underlying pool-resize error

Example fix

// before
value="50 connections"
// after
value="50"
Defensive patterns

Strategy: validation

Validate before calling

value := "50"
if _, err := strconv.Atoi(value); err != nil {
    return fmt.Errorf("%s is not a valid integer pool size", value)
}
current := tsv.PoolSize() // ensure new size >= currently in-use connections
// then POST /debug/env?varname=ReadPoolSize&value=50

Try / catch

resp, err := http.PostForm(url, url.Values{"varname": {"ReadPoolSize"}, "value": {"50"}})
if resp.StatusCode == http.StatusBadRequest {
    body, _ := io.ReadAll(resp.Body)
    var inner string
    if _, perr := fmt.Sscanf(string(body), "failed setting value for %v: %v", new(interface{}), &inner); perr == nil {
        log.Warn("pool resize rejected", slog.String("cause", inner))
    }
}

Prevention

When it happens

Trigger: POST /debug/env with varname ReadPoolSize/StreamPoolSize/TransactionPoolSize where the value is non-numeric (Atoi fails) or the setter function returns an error under the request context — such as resizing a pool to an invalid/too-small size or a context cancellation mid-call.

Common situations: Operators setting pool sizes with units or separators; shrinking a pool below the number of currently checked-out connections; request context cancelled (client disconnected) while the resize was applied.

Related errors


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