{"record":{"id":"eaf97576f92fe112","repo":"thanos-io/thanos","slug":"level-is-bigger-then-default-set-of-d","errorCode":null,"errorMessage":"level is bigger then default set of %d","messagePattern":"level is bigger then default set of (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/compact.go","lineNumber":78,"sourceCode":"\t\t2 * 24 * time.Hour,\n\t\t14 * 24 * time.Hour,\n\t}\n)\n\ntype compactionSet []time.Duration\n\nfunc (cs compactionSet) String() string {\n\tresult := make([]string, len(cs))\n\tfor i, c := range cs {\n\t\tresult[i] = fmt.Sprintf(\"%d=%dh\", i, int(c.Hours()))\n\t}\n\treturn strings.Join(result, \", \")\n}\n\n// levels returns set of compaction levels not higher than specified max compaction level.\nfunc (cs compactionSet) levels(maxLevel int) ([]int64, error) {\n\tif maxLevel >= len(cs) {\n\t\treturn nil, errors.Errorf(\"level is bigger then default set of %d\", len(cs))\n\t}\n\n\tlevels := make([]int64, maxLevel+1)\n\tfor i, c := range cs[:maxLevel+1] {\n\t\tlevels[i] = int64(c / time.Millisecond)\n\t}\n\treturn levels, nil\n}\n\n// maxLevel returns max available compaction level.\nfunc (cs compactionSet) maxLevel() int {\n\treturn len(cs) - 1\n}\n\nfunc registerCompact(app *extkingpin.App) {\n\tcmd := app.Command(component.Compact.String(), \"Continuously compacts blocks in an object store bucket.\")\n\tconf := &compactConfig{}\n\tconf.registerFlag(cmd)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/compact.go#L60-L96","documentation":"compactionSet.levels builds the list of compaction levels up to a requested max level. It refuses when maxLevel indexes past the end of the configured level set (maxLevel >= len(cs)), since there is no such level to slice. The message is a wrap-style plain error with the size of the default set interpolated.","triggerScenarios":"Calling levels(n) (directly or via runCompact with --max-compaction-level) where n is >= the number of entries in the compactionSet (e.g. maxCompactionLevel 5+ on a set of 5 levels).","commonSituations":"Operators set a too-high --max-compaction-level flag on thanos compact, misunderstanding it as a bucket-wide max level rather than an index into Thanos' default compaction levels.","solutions":["Lower --max-compaction-level to a value within the default set (0..len-1).","Omit --max-compaction-level entirely to use the default.","Check the configured compaction set size with compactions.maxLevel() and clamp before calling levels()."],"exampleFix":"// before\nthanos compact --max-compaction-level=5 ...\n// after\nthanos compact --max-compaction-level=2 ...  # or omit the flag","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", addr, 5*time.Second)\nif err != nil { return err }\nconn.Close()","typeGuard":null,"tryCatchPattern":"if errors.As(err, &be) && strings.Contains(err.Error(), \"failed to bootstrap capnp writer\") { time.Sleep(backoff); return retry() }","preventionTips":["Use generous ctx timeout","Health-check receiver","Enable reconnect backoff"],"tags":["config","compaction","cli"],"backgroundTag":"value-out-of-range","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"}