From 67565b9bca19ac288f8dc1e47f477875664428ca Mon Sep 17 00:00:00 2001 From: Yi Jin Date: Fri, 20 Dec 2024 12:03:44 -0800 Subject: [PATCH] per tenant compactor backlogs Signed-off-by: Yi Jin --- cmd/thanos/compact.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/thanos/compact.go b/cmd/thanos/compact.go index f2a8290afe..c3d1ca5860 100644 --- a/cmd/thanos/compact.go +++ b/cmd/thanos/compact.go @@ -462,6 +462,11 @@ func runCompact( } compactMainFn := func() error { + // this should happen before any compaction to remove unnecessary process on backlogs beyond retention. + if err := compact.ApplyRetentionPolicyByTenant(ctx, logger, insBkt, sy.Metas(), retentionByTenant, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, metadata.TenantRetentionExpired)); err != nil { + return errors.Wrap(err, "retention by tenant failed") + } + if err := compactor.Compact(ctx); err != nil { return errors.Wrap(err, "whole compaction error") } @@ -540,10 +545,6 @@ func runCompact( return errors.Wrap(err, "sync before retention") } - if err := compact.ApplyRetentionPolicyByTenant(ctx, logger, insBkt, sy.Metas(), retentionByTenant, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, metadata.TenantRetentionExpired)); err != nil { - return errors.Wrap(err, "retention by tenant failed") - } - if err := compact.ApplyRetentionPolicyByResolution(ctx, logger, insBkt, sy.Metas(), retentionByResolution, compactMetrics.blocksMarked.WithLabelValues(metadata.DeletionMarkFilename, "")); err != nil { return errors.Wrap(err, "retention failed") }