avoid inconsistent versions healing when versions are large (#16066)

This commit is contained in:
Harshavardhana 2022-11-14 18:35:26 -08:00 committed by GitHub
parent 7c5e4da90c
commit 91f45c4aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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