fix: heal optimizations in crawler to avoid multiple healing attempts (#11173)

Fixes two problems

- Double healing when bitrot is enabled, instead heal attempt
  once in applyActions() before lifecycle is applied.

- If applyActions() is successful and getSize() returns proper
  value, then object is accounted for and should be removed
  from the oldCache namespace map to avoid double heal attempts.
This commit is contained in:
Harshavardhana
2020-12-28 10:31:00 -08:00
committed by GitHub
parent d8d25a308f
commit 445a9bd827
4 changed files with 113 additions and 88 deletions

View File

@@ -50,7 +50,6 @@ import (
"github.com/minio/minio/pkg/disk"
"github.com/minio/minio/pkg/env"
xioutil "github.com/minio/minio/pkg/ioutil"
"github.com/minio/minio/pkg/madmin"
)
const (
@@ -391,31 +390,13 @@ func (s *xlStorage) CrawlAndGetDataUsage(ctx context.Context, cache dataUsageCac
}
oi := version.ToObjectInfo(item.bucket, item.objectPath())
if objAPI != nil {
size := item.applyActions(ctx, objAPI, actionMeta{
totalSize += item.applyActions(ctx, objAPI, actionMeta{
numVersions: numVersions,
successorModTime: successorModTime,
oi: oi,
bitRotScan: healOpts.Bitrot,
})
if !version.Deleted {
// Bitrot check local data
if size > 0 && item.heal && healOpts.Bitrot {
// HealObject verifies bitrot requirement internally
res, err := objAPI.HealObject(ctx, item.bucket, item.objectPath(), oi.VersionID, madmin.HealOpts{
Remove: healDeleteDangling,
ScanMode: madmin.HealDeepScan,
})
if err != nil {
if !errors.Is(err, NotImplemented{}) {
logger.LogIf(ctx, err)
}
size = 0
} else {
size = res.ObjectSize
}
}
totalSize += size
}
item.healReplication(ctx, objAPI, actionMeta{oi: version.ToObjectInfo(item.bucket, item.objectPath())}, &sizeS)
item.healReplication(ctx, objAPI, oi, &sizeS)
}
}
sizeS.totalSize = totalSize