{"record":{"id":"6f78177b889332a7","repo":"thanos-io/thanos","slug":"invalid-maximum-pool-size","errorCode":null,"errorMessage":"invalid maximum pool size","messagePattern":"invalid maximum pool size","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pool/pool.go","lineNumber":62,"sourceCode":"// Useful for package internal pools.\nfunc MustNewBucketedPool[T any](minSize, maxSize int, factor float64, maxTotal uint64) *BucketedPool[T] {\n\tpool, err := NewBucketedPool[T](minSize, maxSize, factor, maxTotal)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn pool\n}\n\n// NewBucketedPool returns a new BucketedPool with size buckets for minSize to\n// maxSize increasing by the given factor and maximum number of used items. No\n// more than maxTotal items can be used at any given time unless maxTotal is set\n// to 0.\nfunc NewBucketedPool[T any](minSize, maxSize int, factor float64, maxTotal uint64) (*BucketedPool[T], error) {\n\tif minSize < 1 {\n\t\treturn nil, errors.New(\"invalid minimum pool size\")\n\t}\n\tif maxSize < 1 {\n\t\treturn nil, errors.New(\"invalid maximum pool size\")\n\t}\n\tif factor < 1 {\n\t\treturn nil, errors.New(\"invalid factor\")\n\t}\n\n\tvar sizes []int\n\n\tfor s := minSize; s <= maxSize; s = int(float64(s) * factor) {\n\t\tsizes = append(sizes, s)\n\t}\n\tp := &BucketedPool[T]{\n\t\tbuckets:  make([]sync.Pool, len(sizes)),\n\t\tsizes:    sizes,\n\t\tmaxTotal: maxTotal,\n\t\tnew: func(sz int) *[]T {\n\t\t\ts := make([]T, 0, sz)\n\t\t\treturn &s\n\t\t},","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/pool/pool.go#L44-L80","documentation":"NewBucketedPool requires the maximum bucket size to be at least 1. A maxSize < 1 cannot host any allocation and breaks the bucket size ladder built from minSize up to maxSize. Returned at construction time.","triggerScenarios":"Calling NewBucketedPool[T](minSize, 0, ...) or negative maxSize; also occurs when minSize > maxSize such that computed sizes end up empty, but the direct trigger is maxSize < 1.","commonSituations":"Config flag for max chunk pool size set to 0 or unset and defaulted to 0; unit tests probing pool validation.","solutions":["Pass maxSize >= 1 and ensure maxSize >= minSize","Validate config-derived sizes before constructing the pool","Use the default pool helpers (NewDefaultChunkBytesPool) if custom sizing is not needed"],"exampleFix":"// before\npool, err := pool.NewBucketedPool[byte](1<<10, maxChunkSize, 2, 0)\n// after\nif maxChunkSize < (1 << 10) { maxChunkSize = 1 << 22 }\npool, err := pool.NewBucketedPool[byte](1<<10, maxChunkSize, 2, 0)","handlingStrategy":"validation","validationCode":"if maxSize < 1 || maxSize < minSize {\n    return errors.New(\"pool maxSize must be >= 1 and >= minSize\")\n}\npool, err := pool.NewBucketedPool[byte](minSize, maxSize, factor, maxTotal)","typeGuard":null,"tryCatchPattern":"p, err := pool.NewBucketedPool[byte](minSize, maxSize, factor, maxTotal)\nif err != nil {\n    return fmt.Errorf(\"configuring chunk pool: %w\", err)\n}","preventionTips":["Default maxSize flags to a sane nonzero value","Validate maxSize >= minSize before construction","Never pass raw, unvalidated config integers to pool constructors"],"tags":["configuration","pool","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}