thanos-io/thanos · error

could not calculate compaction progress

Error message

could not calculate compaction progress

What it means

ps.ProgressCalculate(ctx, groups) computes compaction progress metrics from the grouped block metadata using the TSDB planner. When it fails, the error is wrapped as 'could not calculate compaction progress'. This is a metrics-only step; its failure stops the progress iteration but not compaction itself.

Solutions

  1. Check the wrapped inner error for the failing group/block and inspect those blocks with 'thanos tools bucket inspect'.
  2. Verify no overlapping/duplicate blocks exist (fix upstream grouping errors first).
  3. Restart the compactor; the calculation repeats on the next progressCalculateInterval tick.
  4. Upgrade Thanos if the planner panics/errors on valid metadata (known regressions fixed in later releases).

Example fix

null
Defensive patterns

Strategy: try-catch

Try / catch

if err := ps.ProgressCalculate(ctx, groups); err != nil {
    if ctx.Err() != nil {
        return nil // shutting down; benign
    }
    log.Errorf("could not calculate compaction progress: %v", err)
    return nil // metrics step; don't kill the worker
}

Prevention

When it happens

Trigger: The CompactionProgressCalculator's internal planner (tsdbPlanner) throws while estimating remaining compaction work — e.g. inconsistent group state after partial sync, or internal key/parse issues in the group's block set.

Common situations: Rare; usually follows a preceding grouping anomaly (overlapping blocks) or a bug in the planner when fed unusual block distributions. Also seen when ctx is cancelled during calculation in a shutting-down process.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/compact.go:670

						// You should alert on this being triggered too frequently.
						if compact.IsRetryError(err) {
							level.Error(logger).Log("msg", "retriable error", "err", err)
							compactMetrics.retried.Inc()

							return nil
						}

						return errors.Wrapf(err, "could not sync metas")
					}

					metas := sy.Metas()
					groups, err := grouper.Groups(metas)
					if err != nil {
						return errors.Wrapf(err, "could not group metadata for compaction")
					}

					if err = ps.ProgressCalculate(ctx, groups); err != nil {
						return errors.Wrapf(err, "could not calculate compaction progress")
					}

					retGroups, err := grouper.Groups(metas)
					if err != nil {
						return errors.Wrapf(err, "could not group metadata for retention")
					}

					if err = rs.ProgressCalculate(ctx, retGroups); err != nil {
						return errors.Wrapf(err, "could not calculate retention progress")
					}

					if !conf.disableDownsampling {
						groups, err = grouper.Groups(metas)
						if err != nil {
							return errors.Wrapf(err, "could not group metadata into downsample groups")
						}
						if err := ds.ProgressCalculate(ctx, groups); err != nil {
							return errors.Wrapf(err, "could not calculate downsampling progress")

View on GitHub (pinned to 35b8b99117)