{"record":{"id":"0005db6a1b670a7a","repo":"thanos-io/thanos","slug":"invalid-minimum-pool-size","errorCode":null,"errorMessage":"invalid minimum pool size","messagePattern":"invalid minimum pool size","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pool/pool.go","lineNumber":59,"sourceCode":"}\n\n// MustNewBucketedPool is like NewBucketedPool but panics if construction fails.\n// 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 {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/pool/pool.go#L41-L77","documentation":"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.","triggerScenarios":"Calling NewBucketedPool[T](0, maxSize, factor, maxTotal) or a negative minSize, typically via config-derived sizes like MinChunkSize/bytes pool settings.","commonSituations":"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.","solutions":["Pass minSize >= 1 (commonly 1 KB or 512 B for chunk pools)","Clamp parsed config values: if minSize < 1 { minSize = 1 }","Use MustNewBucketedPool only with constant, known-valid sizes"],"exampleFix":"// before\npool, err := pool.NewBucketedPool[byte](minChunkSize, 1<<22, 2, 0)\n// after\nif minChunkSize < 1 { minChunkSize = 1 }\npool, err := pool.NewBucketedPool[byte](minChunkSize, 1<<22, 2, 0)","handlingStrategy":"validation","validationCode":"if minSize < 1 {\n    return errors.New(\"pool minSize must be >= 1\")\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":["Sanity-check all size config values (>0) at config load time","Use the default pool constructors when custom sizes are unnecessary","Add unit tests for pool construction with config-derived values"],"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"}