thanos-io/thanos · error

create compactor

Error message

create compactor

What it means

Wraps an error from tsdb.NewLeveledCompactor when instantiating the leveled compactor with the computed levels, downsample pool and merge func. Failures are rare and typically mean the compactor could not be initialized (e.g. invalid levels slice or pool creation failure).

Solutions

  1. Inspect the wrapped cause in logs and address the underlying initialization error.
  2. Verify --max-compaction-level produces a sane levels list (see related level errors).
  3. Retry startup; report to Thanos upstream if it reproduces with default flags.
Defensive patterns

Strategy: try-catch

Try / catch

if err := runCompact(...); err != nil {
    if strings.Contains(err.Error(), "create compactor") {
        logger.Error(err, "compactor init failed; verify flags/levels and retry with defaults")
    }
    return err
}

Prevention

When it happens

Trigger: tsdb.NewLeveledCompactor returns an error during startup, most plausibly from internal initialization with the given levels/mergeFunc parameters.

Common situations: Practically seen only with corrupted upstream setups, custom builds with modified level lists, or memory/registration issues during process bring-up.

Related errors


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

Appendix: source

Thrown at cmd/thanos/compact.go:347

	switch conf.dedupFunc {
	case compact.DedupAlgorithmPenalty:
		mergeFunc = dedup.NewChunkSeriesMerger()

		if len(dedupReplicaLabels) == 0 {
			return errors.New("penalty based deduplication needs at least one replica label specified")
		}
	case "":
		mergeFunc = storage.NewCompactingChunkSeriesMerger(storage.ChainedSeriesMerge)

	default:
		return errors.Errorf("unsupported deduplication func, got %s", conf.dedupFunc)
	}

	// Instantiate the compactor with different time slices. Timestamps in TSDB
	// are in milliseconds.
	comp, err := tsdb.NewLeveledCompactor(ctx, reg, logutil.GoKitLogToSlog(logger), levels, downsample.NewPool(), mergeFunc)
	if err != nil {
		return errors.Wrap(err, "create compactor")
	}

	var (
		compactDir      = path.Join(conf.dataDir, "compact")
		downsamplingDir = path.Join(conf.dataDir, "downsample")
	)

	if err := os.MkdirAll(compactDir, os.ModePerm); err != nil {
		return errors.Wrap(err, "create working compact directory")
	}

	if err := os.MkdirAll(downsamplingDir, os.ModePerm); err != nil {
		return errors.Wrap(err, "create working downsample directory")
	}

	grouper := compact.NewDefaultGrouper(
		logger,
		insBkt,

View on GitHub (pinned to 35b8b99117)