thanos-io/thanos · error

build compaction groups

Error message

build compaction groups

What it means

Wraps grouper.Groups when partitioning the synced block metadata into compaction groups: the grouping criteria (labels, resolution, time ranges) could not be applied — typically conflicting or malformed Thanos metadata among blocks. No compaction plan can be built.

Solutions

  1. Identify overlapping blocks from the wrapped error
  2. Remove duplicate/overlapping blocks or enable vertical compaction
  3. Check for multiple compactors writing to the bucket
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/compact/compact.go:1587 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/d8ac77eb01f3b3b4. Report an issue: GitHub.

Appendix: source

Thrown at pkg/compact/compact.go:1587

		}

		var ignoreBlocks map[ulid.ULID]struct{}
		if c.blocksCleaner != nil {
			deletedBlocks, err := c.blocksCleaner.DeleteMarkedBlocks(ctx)
			if err != nil {
				return errors.Wrap(err, "cleaning marked blocks")
			}
			ignoreBlocks = deletedBlocks
		}

		level.Info(c.logger).Log("msg", "start of initial garbage collection")
		if err := c.sy.GarbageCollect(ctx, ignoreBlocks); err != nil {
			return errors.Wrap(err, "garbage")
		}

		groups, err := c.grouper.Groups(c.sy.Metas())
		if err != nil {
			return errors.Wrap(err, "build compaction groups")
		}

		ignoreDirs := []string{}
		for _, gr := range groups {
			for _, grID := range gr.IDs() {
				ignoreDirs = append(ignoreDirs, filepath.Join(gr.Key(), grID.String()))
			}
		}

		if err := runutil.DeleteAll(c.compactDir, ignoreDirs...); err != nil {
			level.Warn(c.logger).Log("msg", "failed deleting non-compaction group directories/files, some disk space usage might have leaked. Continuing", "err", err, "dir", c.compactDir)
		}

		level.Info(c.logger).Log("msg", "start of compactions")

		// Send all groups found during this pass to the compaction workers.
		var groupErrs errutil.MultiError
	groupLoop:

View on GitHub (pinned to 35b8b99117)