thanos-io/thanos · error
level is bigger then default set of
Error message
level is bigger then default set of %d
What it means
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.
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().
Example fix
// before thanos compact --max-compaction-level=5 ... // after thanos compact --max-compaction-level=2 ... # or omit the flag
Defensive patterns
Strategy: retry
Validate before calling
conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
if err != nil { return err }
conn.Close() Try / catch
if errors.As(err, &be) && strings.Contains(err.Error(), "failed to bootstrap capnp writer") { time.Sleep(backoff); return retry() } Prevention
- Use generous ctx timeout
- Health-check receiver
- Enable reconnect backoff
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- get compaction levels
- unknown sync strategy
- penalty based deduplication needs at least one replica…
- unrecognized label
- unsupported format for label
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/eaf97576f92fe112.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/compact.go:78
2 * 24 * time.Hour,
14 * 24 * time.Hour,
}
)
type compactionSet []time.Duration
func (cs compactionSet) String() string {
result := make([]string, len(cs))
for i, c := range cs {
result[i] = fmt.Sprintf("%d=%dh", i, int(c.Hours()))
}
return strings.Join(result, ", ")
}
// levels returns set of compaction levels not higher than specified max compaction level.
func (cs compactionSet) levels(maxLevel int) ([]int64, error) {
if maxLevel >= len(cs) {
return nil, errors.Errorf("level is bigger then default set of %d", len(cs))
}
levels := make([]int64, maxLevel+1)
for i, c := range cs[:maxLevel+1] {
levels[i] = int64(c / time.Millisecond)
}
return levels, nil
}
// maxLevel returns max available compaction level.
func (cs compactionSet) maxLevel() int {
return len(cs) - 1
}
func registerCompact(app *extkingpin.App) {
cmd := app.Command(component.Compact.String(), "Continuously compacts blocks in an object store bucket.")
conf := &compactConfig{}
conf.registerFlag(cmd)View on GitHub (pinned to 35b8b99117)