diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5ca78c2f..3d9df9519c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#5641](https://github.com/thanos-io/thanos/pull/5641) Query: Inject unshardable le label in query analyzer. - [#5685](https://github.com/thanos-io/thanos/pull/5685) Receive: Make active/head series limiting configuration per tenant by adding it to new limiting config. - [#5411](https://github.com/thanos-io/thanos/pull/5411) Tracing: Change Jaeger exporter from OpenTracing to OpenTelemetry. *Options `RPC Metrics`, `Gen128Bit` and `Disabled` are now deprecated and won't have any effect when set :warning:.* +- [#5766](https://github.com/thanos-io/thanos/pull/5766) Compact: Apply retention before compaction. ### Removed diff --git a/cmd/thanos/compact.go b/cmd/thanos/compact.go index 166aa5d7c9..6c910f8f79 100644 --- a/cmd/thanos/compact.go +++ b/cmd/thanos/compact.go @@ -420,6 +420,15 @@ func runCompact( } compactMainFn := func() error { + // TODO(bwplotka): Find a way to avoid syncing if no op was done. + if err := sy.SyncMetas(ctx); err != nil { + return errors.Wrap(err, "sync before retention") + } + + if err := compact.ApplyRetentionPolicyByResolution(ctx, logger, bkt, sy.Metas(), retentionByResolution, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, "")); err != nil { + return errors.Wrap(err, "retention failed") + } + if err := compactor.Compact(ctx); err != nil { return errors.Wrap(err, "compaction") } @@ -454,15 +463,6 @@ func runCompact( level.Info(logger).Log("msg", "downsampling was explicitly disabled") } - // TODO(bwplotka): Find a way to avoid syncing if no op was done. - if err := sy.SyncMetas(ctx); err != nil { - return errors.Wrap(err, "sync before retention") - } - - if err := compact.ApplyRetentionPolicyByResolution(ctx, logger, bkt, sy.Metas(), retentionByResolution, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, "")); err != nil { - return errors.Wrap(err, "retention failed") - } - return cleanPartialMarked() }