thanos-io/thanos · error

invalid minimum pool size

Error message

invalid minimum pool size

What it means

NewBucketedPool validates that the minimum bucket size is at least 1 byte/element. A minSize < 1 would create zero- or negative-size pool buckets, which is meaningless for byte pools. It is returned at construction time so misconfiguration fails fast.

Solutions

  1. Pass minSize >= 1 (commonly 1 KB or 512 B for chunk pools)
  2. Clamp parsed config values: if minSize < 1 { minSize = 1 }
  3. Use MustNewBucketedPool only with constant, known-valid sizes

Example fix

// before
pool, err := pool.NewBucketedPool[byte](minChunkSize, 1<<22, 2, 0)
// after
if minChunkSize < 1 { minChunkSize = 1 }
pool, err := pool.NewBucketedPool[byte](minChunkSize, 1<<22, 2, 0)
Defensive patterns

Strategy: validation

Validate before calling

if minSize < 1 {
    return errors.New("pool minSize must be >= 1")
}
pool, err := pool.NewBucketedPool[byte](minSize, maxSize, factor, maxTotal)

Try / catch

p, err := pool.NewBucketedPool[byte](minSize, maxSize, factor, maxTotal)
if err != nil {
    return fmt.Errorf("configuring chunk pool: %w", err)
}

Prevention

When it happens

Trigger: Calling NewBucketedPool[T](0, maxSize, factor, maxTotal) or a negative minSize, typically via config-derived sizes like MinChunkSize/bytes pool settings.

Common situations: Config file or flag sets chunk pool min size to 0; code computing sizes from a multiplier that rounds to zero; tests constructing pools with placeholder values.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/0005db6a1b670a7a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/pool/pool.go:59

}

// MustNewBucketedPool is like NewBucketedPool but panics if construction fails.
// Useful for package internal pools.
func MustNewBucketedPool[T any](minSize, maxSize int, factor float64, maxTotal uint64) *BucketedPool[T] {
	pool, err := NewBucketedPool[T](minSize, maxSize, factor, maxTotal)
	if err != nil {
		panic(err)
	}
	return pool
}

// NewBucketedPool returns a new BucketedPool with size buckets for minSize to
// maxSize increasing by the given factor and maximum number of used items. No
// more than maxTotal items can be used at any given time unless maxTotal is set
// to 0.
func NewBucketedPool[T any](minSize, maxSize int, factor float64, maxTotal uint64) (*BucketedPool[T], error) {
	if minSize < 1 {
		return nil, errors.New("invalid minimum pool size")
	}
	if maxSize < 1 {
		return nil, errors.New("invalid maximum pool size")
	}
	if factor < 1 {
		return nil, errors.New("invalid factor")
	}

	var sizes []int

	for s := minSize; s <= maxSize; s = int(float64(s) * factor) {
		sizes = append(sizes, s)
	}
	p := &BucketedPool[T]{
		buckets:  make([]sync.Pool, len(sizes)),
		sizes:    sizes,
		maxTotal: maxTotal,
		new: func(sz int) *[]T {

View on GitHub (pinned to 35b8b99117)