grpc/grpc-go · error

max_ring_size value of

Error message

max_ring_size value of %d is greater than max supported value %d for this field

What it means

Returned by ringhash's parseConfig() (balancer/ringhash/config.go:46) when MaxRingSize exceeds ringHashSizeUpperBound (8388608). Same memory-safety cap as minRingSize. maxRingSize bounds the largest the hash ring can grow; exceeding 8M entries is rejected.

Solutions

  1. Set maxRingSize to a value <= 8388608 (8M).
  2. Use the default (defaultMaxSize = 4096) for most deployments.
  3. Ensure minRingSize <= maxRingSize after capping.

Example fix

// before: maxRingSize beyond the hard cap
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig":[{"ring_hash_experimental":{"maxRingSize":16000000}}]}`)

// after: within the supported range
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig":[{"ring_hash_experimental":{"minRingSize":1024,"maxRingSize":4096}}]}`)
Defensive patterns

Strategy: validation

Validate before calling

const ringHashUpperBound = 8 * 1024 * 1024
func validateMaxRingSize(max uint64) error {
    if max > ringHashUpperBound {
        return fmt.Errorf("maxRingSize %d exceeds max %d", max, ringHashUpperBound)
    }
    return nil
}

Prevention

When it happens

Trigger: The ring_hash_experimental config sets maxRingSize to a value > 8388608. The check at line 45 fails.

Common situations: xDS control plane pushes an oversized maxRingSize; operator sets a huge value for finer-grained hashing; a config typo.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/7bae25ac94fe7435. Report an issue: GitHub.

Appendix: source

Thrown at balancer/ringhash/config.go:46

	iringhash "google.golang.org/grpc/internal/ringhash"
)

const (
	defaultMinSize         = 1024
	defaultMaxSize         = 4096
	ringHashSizeUpperBound = 8 * 1024 * 1024 // 8M
)

func parseConfig(c json.RawMessage) (*iringhash.LBConfig, error) {
	var cfg iringhash.LBConfig
	if err := json.Unmarshal(c, &cfg); err != nil {
		return nil, err
	}
	if cfg.MinRingSize > ringHashSizeUpperBound {
		return nil, fmt.Errorf("min_ring_size value of %d is greater than max supported value %d for this field", cfg.MinRingSize, ringHashSizeUpperBound)
	}
	if cfg.MaxRingSize > ringHashSizeUpperBound {
		return nil, fmt.Errorf("max_ring_size value of %d is greater than max supported value %d for this field", cfg.MaxRingSize, ringHashSizeUpperBound)
	}
	if cfg.MinRingSize == 0 {
		cfg.MinRingSize = defaultMinSize
	}
	if cfg.MaxRingSize == 0 {
		cfg.MaxRingSize = defaultMaxSize
	}
	if cfg.MinRingSize > cfg.MaxRingSize {
		return nil, fmt.Errorf("min %v is greater than max %v", cfg.MinRingSize, cfg.MaxRingSize)
	}
	if cfg.MinRingSize > envconfig.RingHashCap {
		cfg.MinRingSize = envconfig.RingHashCap
	}
	if cfg.MaxRingSize > envconfig.RingHashCap {
		cfg.MaxRingSize = envconfig.RingHashCap
	}
	if !envconfig.RingHashSetRequestHashKey {
		cfg.RequestHashHeader = ""

View on GitHub (pinned to 0c51461d27)