From 91f45c4aa60c1a3e0a1c21b687da26f35d7d4f5b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 14 Nov 2022 18:35:26 -0800 Subject: [PATCH] avoid inconsistent versions healing when versions are large (#16066) --- cmd/erasure-object.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 27270e7b5..a9a3b6bb6 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -1253,17 +1253,21 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st return nil } } + fivs, err := entry.fileInfoVersions(bucket) if err != nil { - _, err = er.HealObject(ctx, bucket, entry.name, "", madmin.HealOpts{NoLock: true}) + healObject(bucket, entry.name, "", madmin.HealNormalScan) return err } + if len(fivs.Versions) > 2 { + return fmt.Errorf("bucket(%s)/object(%s) object with %d versions needs healing, allowing lazy healing via scanner instead here for versions greater than 2", + bucket, entry.name, + len(fivs.Versions)) + } + for _, version := range fivs.Versions { - _, err = er.HealObject(ctx, bucket, version.Name, version.VersionID, madmin.HealOpts{NoLock: true}) - if err != nil && !isErrObjectNotFound(err) && !isErrVersionNotFound(err) { - return err - } + healObject(bucket, entry.name, version.VersionID, madmin.HealNormalScan) } return nil