{"record":{"id":"0c0a535021515bb9","repo":"thanos-io/thanos","slug":"invalid-factor","errorCode":null,"errorMessage":"invalid factor","messagePattern":"invalid factor","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pool/pool.go","lineNumber":65,"sourceCode":"\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},\n\t}\n\treturn p, nil\n}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/pool/pool.go#L47-L83","documentation":"The bucket growth factor in NewBucketedPool must be >= 1. Each bucket size is computed by multiplying the previous size by factor until maxSize; a factor < 1 would shrink toward zero and generate an invalid/degenerate bucket ladder.","triggerScenarios":"NewBucketedPool[T](minSize, maxSize, 0.5, maxTotal) or factor 0 / negative, usually from a misread config option for pool growth.","commonSituations":"Tuning pool memory by setting a fractional 'growth' value; copy-paste of factor as percentage 0.5 intending 1.5 or 2.","solutions":["Pass a factor >= 1; use 2 for doubling (common default)","If a percentage was intended, convert it: factor = 1 + pct/100","Validate the config value before constructing the pool"],"exampleFix":"// before\npool, err := pool.NewBucketedPool[byte](1<<10, 1<<22, 0.5, 0)\n// after\npool, err := pool.NewBucketedPool[byte](1<<10, 1<<22, 2.0, 0)","handlingStrategy":"validation","validationCode":"if factor < 1 {\n    return errors.New(\"pool growth factor 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":["Use constants like 2.0 for the factor instead of config-derived floats","If the value is a percentage, convert to a multiplicative factor first","Document the factor semantics (multiplicative growth, not percent)"],"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"}