vitessio/vitess · error
maxSize can't be less than minSize
Error message
maxSize can't be less than minSize
What it means
bucketpool.New builds buckets from minSize up to maxSize, doubling each time; it panics if maxSize < minSize because no valid bucket range would exist. This is a programming error guarded at construction time.
Source
Thrown at go/bucketpool/bucketpool.go:51
New: func() any { return makeSlicePointer(size) },
},
}
}
// Pool is actually multiple pools which store buffers of specific size.
// i.e. it can be three pools which return buffers 32K, 64K and 128K.
type Pool struct {
minSize int
maxSize int
pools []*sizedPool
}
// New returns Pool which has buckets from minSize to maxSize.
// Buckets increase with the power of two, i.e with multiplier 2: [2b, 4b, 16b, ... , 1024b]
// Last pool will always be capped to maxSize.
func New(minSize, maxSize int) *Pool {
if maxSize < minSize {
panic("maxSize can't be less than minSize")
}
const multiplier = 2
var pools []*sizedPool
curSize := minSize
for curSize < maxSize {
pools = append(pools, newSizedPool(curSize))
curSize *= multiplier
}
pools = append(pools, newSizedPool(maxSize))
return &Pool{
minSize: minSize,
maxSize: maxSize,
pools: pools,
}
}
func (p *Pool) findPool(size int) *sizedPool {
if size > p.maxSize {View on GitHub (pinned to 01a25a7d17)
Solutions
- Pass arguments in the correct order: New(minSize, maxSize)
- Validate config at load time so maxSize >= minSize before constructing the pool
- If the caller computes sizes dynamically, clamp maxSize up to minSize
Example fix
// before pool := bucketpool.New(8192, 1024) // swapped // after pool := bucketpool.New(1024, 8192)
Defensive patterns
Strategy: validation
Validate before calling
func safeNewBucketPool(minSize, maxSize int) *bucketpool.Pool {
if maxSize < minSize {
panic(fmt.Sprintf("invalid bucket pool sizes: min=%d max=%d", minSize, maxSize))
}
return bucketpool.New(minSize, maxSize)
} Type guard
func validPoolSizes(minSize, maxSize int) bool { return maxSize >= minSize } Try / catch
defer func() {
if r := recover(); r != nil {
log.Errorf("bucketpool construction failed: %v", r)
}
}() Prevention
- Validate size config at startup before constructing pools
- Keep min/max size constants adjacent to avoid argument swap
- Add unit tests covering boundary sizes
When it happens
Trigger: Calling bucketpool.New(minSize, maxSize) with maxSize less than minSize, e.g. swapped arguments or a config where the max buffer size was reduced below the min.
Common situations: Swapped parameters (New(max, min)); configuration validation done in the wrong order; tests probing boundary behavior.
Related errors
- this command panics on purpose
- failed to load flag for %s: %w
- uncaught panic: %v
- QueryRowsMap unexpected error: %+v
- ExecNoPrepare unexpected error: %+v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/5cda02736c2a3b14.
Report an issue: GitHub.