thanos-io/thanos · error

unexpected downsampling resolution

Error message

unexpected downsampling resolution %d

What it means

downsampleBucket scans existing block metas to decide which source blocks to ignore, and errors with errors.Errorf when a block's meta.Thanos.Downsample.Resolution is not one of the known levels (0, ResLevel1=5m, ResLevel2=60m). This indicates a meta.json with a corrupted or unknown downsampling resolution value.

Solutions

  1. Identify the offending block (log/scan its meta.json thanos.downsample.resolution) and delete or re-upload a correct meta.json for it.
  2. Check the Thanos version that wrote the block; upgrade the running downsample binary to match the bucket's block versions.
  3. If meta.json is corrupted, remove the partial block from the object store so the compactor/downsampler can reprocess sources.
Defensive patterns

Strategy: validation

Validate before calling

var resolution int64
if err := json.Unmarshal(meta.Thanos.Downsample.Resolution, &resolution); err != nil { /* corrupt */ }
switch resolution {
case 0, 300000, 3600000:
default:
    log.Printf("block %s has invalid resolution %d", meta.ULID, resolution)
}

Type guard

func validResolution(r int64) bool { return r == 0 || r == 300000 || r == 3600000 }

Prevention

When it happens

Trigger: A block in the bucket has meta.json whose thanos.downsample.resolution is neither 0, 300000, nor 3600000 — e.g. a hand-edited or corrupted meta, or a block written by an incompatible/future version with a new resolution level.

Common situations: Manually copying blocks between buckets and editing meta.json; blocks produced by a patched/older Thanos with different resolution encoding; truncated meta.json uploads from failed uploads.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/downsample.go:224

	// mapping from a hash over all source IDs to blocks. We don't need to downsample a block
	// if a downsampled version with the same hash already exists.
	sources5m := map[ulid.ULID]struct{}{}
	sources1h := map[ulid.ULID]struct{}{}

	for _, m := range metas {
		switch m.Thanos.Downsample.Resolution {
		case downsample.ResLevel0:
			continue
		case downsample.ResLevel1:
			for _, id := range m.Compaction.Sources {
				sources5m[id] = struct{}{}
			}
		case downsample.ResLevel2:
			for _, id := range m.Compaction.Sources {
				sources1h[id] = struct{}{}
			}
		default:
			return errors.Errorf("unexpected downsampling resolution %d", m.Thanos.Downsample.Resolution)
		}
	}

	ignoreDirs := []string{}
	for ulid := range metas {
		ignoreDirs = append(ignoreDirs, ulid.String())
	}

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

	metasULIDS := make([]ulid.ULID, 0, len(metas))
	for k := range metas {
		metasULIDS = append(metasULIDS, k)
	}
	sort.Slice(metasULIDS, func(i, j int) bool {
		return metasULIDS[i].Compare(metasULIDS[j]) < 0

View on GitHub (pinned to 35b8b99117)