thanos-io/thanos · error

requested to mark for no deletion, but file already exists…

Error message

requested to mark for no deletion, but file already exists; this should not happen; investigate

What it means

A warn-level log guard in MarkForNoDownsample: a no-downsample mark file already exists for this block in the bucket, so the requested (re-)marking is skipped as already done. It is flagged as 'should not happen' because callers are expected to check the mark before requesting it; the underlying sentinel error naming the existing file is attached as err.

Solutions

  1. Verify why the block is marked twice
  2. No action needed — the mark is already present
  3. Check compactor/downsample logic for repeated marking
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at pkg/block/block.go:421 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/d9bf5b762005f5c0. Report an issue: GitHub.

Appendix: source

Thrown at pkg/block/block.go:421

	}

	if err := bkt.Upload(ctx, m, bytes.NewBuffer(noCompactMark)); err != nil {
		return errors.Wrapf(err, "upload file %s to bucket", m)
	}
	markedForNoCompact.Inc()
	level.Info(logger).Log("msg", "block has been marked for no compaction", "block", id)
	return nil
}

// MarkForNoDownsample creates a file which marks block to be not downsampled.
func MarkForNoDownsample(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID, reason metadata.NoDownsampleReason, details string, markedForNoDownsample prometheus.Counter) error {
	m := path.Join(id.String(), metadata.NoDownsampleMarkFilename)
	noDownsampleMarkExists, err := bkt.Exists(ctx, m)
	if err != nil {
		return errors.Wrapf(err, "check exists %s in bucket", m)
	}
	if noDownsampleMarkExists {
		level.Warn(logger).Log("msg", "requested to mark for no deletion, but file already exists; this should not happen; investigate", "err", errors.Errorf("file %s already exists in bucket", m))
		return nil
	}
	noDownsampleMark, err := json.Marshal(metadata.NoDownsampleMark{
		ID:      id,
		Version: metadata.NoDownsampleMarkVersion1,

		NoDownsampleTime: time.Now().Unix(),
		Reason:           reason,
		Details:          details,
	})
	if err != nil {
		return errors.Wrap(err, "json encode no downsample mark")
	}

	if err := bkt.Upload(ctx, m, bytes.NewBuffer(noDownsampleMark)); err != nil {
		return errors.Wrapf(err, "upload file %s to bucket", m)
	}
	markedForNoDownsample.Inc()

View on GitHub (pinned to 35b8b99117)