From 91ebac0a0036597c0dbb1c31e2e74f732ceb642c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 22 Sep 2023 12:07:52 -0700 Subject: [PATCH] fix: move abandoned parts check after healing not in ILM path (#18087) --- cmd/data-scanner.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/data-scanner.go b/cmd/data-scanner.go index abb2469f8..a61327bfb 100644 --- a/cmd/data-scanner.go +++ b/cmd/data-scanner.go @@ -1059,17 +1059,6 @@ func (i *scannerItem) applyNewerNoncurrentVersionLimit(ctx context.Context, _ Ob // applyVersionActions will apply lifecycle checks on all versions of a scanned item. Returns versions that remain // after applying lifecycle checks configured. func (i *scannerItem) applyVersionActions(ctx context.Context, o ObjectLayer, fivs []FileInfo) ([]ObjectInfo, error) { - if i.heal.enabled { - if healDeleteDangling { - done := globalScannerMetrics.time(scannerMetricCleanAbandoned) - err := o.CheckAbandonedParts(ctx, i.bucket, i.objectPath(), madmin.HealOpts{Remove: healDeleteDangling}) - done() - if err != nil { - logger.LogIf(ctx, fmt.Errorf("unable to check object %s/%s for abandoned data: %w", i.bucket, i.objectPath(), err)) - } - } - } - objInfos, err := i.applyNewerNoncurrentVersionLimit(ctx, o, fivs) if err != nil { return nil, err @@ -1110,7 +1099,17 @@ func (i *scannerItem) applyActions(ctx context.Context, o ObjectLayer, oi Object done := globalScannerMetrics.time(scannerMetricHealCheck) size = i.applyHealing(ctx, o, oi) done() + + if healDeleteDangling { + done := globalScannerMetrics.time(scannerMetricCleanAbandoned) + err := o.CheckAbandonedParts(ctx, i.bucket, i.objectPath(), madmin.HealOpts{Remove: healDeleteDangling}) + done() + if err != nil { + logger.LogIf(ctx, fmt.Errorf("unable to check object %s/%s for abandoned data: %w", i.bucket, i.objectPath(), err)) + } + } } + // replicate only if lifecycle rules are not applied. done := globalScannerMetrics.time(scannerMetricCheckReplication) i.healReplication(ctx, o, oi.Clone(), sizeS)