thanos-io/thanos · error

first pass of downsampling failed

Error message

first pass of downsampling failed

What it means

Wrapper error from the first downsampling pass in runCompact (cmd/thanos/compact.go:481) around downsample.DownsampleBucket (or equivalent). An individual block downsampling job failed — the specific block, hash function, or concurrency worker error is wrapped inside.

Solutions

  1. Read the wrapped inner error to identify the failing block and stage
  2. Free disk space or fix volume permissions on the downsampling/data directory
  3. Re-download or delete the corrupt source block (after verifying) so compaction can regenerate it
  4. Match --hash-func with the hash function used when blocks were uploaded
  5. Set --accept-malformed-index only if you understand the malformed index risk
Defensive patterns

Strategy: try-catch

Try / catch

if err := downsampleBucket(...); err != nil {
	level.Error(logger).Log("msg", "first pass downsampling failed", "err", err)
	return errors.Wrap(err, "first pass of downsampling failed")
}

Prevention

When it happens

Trigger: Downsampling a specific block fails: corrupt or unreadable index/chunks files in the local downsampling dir, unsupported hash function, IO errors writing the downsampled block, concurrent workers exhausted context.

Common situations: Disk full on --data-dir volume, malformed blocks flagged by --accept-malformed-index not set, hash function mismatch (e.g. SHA256 vs XXHash) with objects in the bucket.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/compact.go:481

			for _, meta := range filteredMetas {
				resolutionLabel := meta.Thanos.ResolutionString()
				downsampleMetrics.downsamples.WithLabelValues(resolutionLabel)
				downsampleMetrics.downsampleFailures.WithLabelValues(resolutionLabel)
			}

			if err := downsampleBucket(
				ctx,
				logger,
				downsampleMetrics,
				insBkt,
				filteredMetas,
				downsamplingDir,
				conf.downsampleConcurrency,
				conf.blockFilesConcurrency,
				metadata.HashFunc(conf.hashFunc),
				conf.acceptMalformedIndex,
			); err != nil {
				return errors.Wrap(err, "first pass of downsampling failed")
			}

			level.Info(logger).Log("msg", "start second pass of downsampling")
			if err := sy.SyncMetas(ctx); err != nil {
				return errors.Wrap(err, "sync before second pass of downsampling")
			}

			// Regenerate the filtered list of blocks after the sync,
			// to include the blocks created by the first pass.
			filteredMetas = sy.Metas()
			noDownsampleBlocks = noDownsampleMarkerFilter.NoDownsampleMarkedBlocks()
			for ul := range noDownsampleBlocks {
				delete(filteredMetas, ul)
			}

			if err := downsampleBucket(
				ctx,
				logger,

View on GitHub (pinned to 35b8b99117)