mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
xl: Fix locking in xl HealObject (#8455)
Move locking to the correct location, before loading object data.
This commit is contained in:
parent
38e6d911ea
commit
8cc5ecec23
@ -679,6 +679,14 @@ func (xl xlObjects) HealObject(ctx context.Context, bucket, object string, dryRu
|
|||||||
}
|
}
|
||||||
healCtx := logger.SetReqInfo(context.Background(), newReqInfo)
|
healCtx := logger.SetReqInfo(context.Background(), newReqInfo)
|
||||||
|
|
||||||
|
// Lock the object before healing. Use read lock since healing
|
||||||
|
// will only regenerate parts & xl.json of outdated disks.
|
||||||
|
objectLock := xl.nsMutex.NewNSLock(ctx, bucket, object)
|
||||||
|
if lerr := objectLock.GetRLock(globalHealingTimeout); lerr != nil {
|
||||||
|
return madmin.HealResultItem{}, lerr
|
||||||
|
}
|
||||||
|
defer objectLock.RUnlock()
|
||||||
|
|
||||||
// Healing directories handle it separately.
|
// Healing directories handle it separately.
|
||||||
if hasSuffix(object, SlashSeparator) {
|
if hasSuffix(object, SlashSeparator) {
|
||||||
return xl.healObjectDir(healCtx, bucket, object, dryRun)
|
return xl.healObjectDir(healCtx, bucket, object, dryRun)
|
||||||
@ -707,13 +715,6 @@ func (xl xlObjects) HealObject(ctx context.Context, bucket, object string, dryRu
|
|||||||
return defaultHealResult(xlMetaV1{}, storageDisks, errs, bucket, object), toObjectErr(err, bucket, object)
|
return defaultHealResult(xlMetaV1{}, storageDisks, errs, bucket, object), toObjectErr(err, bucket, object)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock the object before healing.
|
|
||||||
objectLock := xl.nsMutex.NewNSLock(ctx, bucket, object)
|
|
||||||
if lerr := objectLock.GetRLock(globalHealingTimeout); lerr != nil {
|
|
||||||
return defaultHealResult(latestXLMeta, storageDisks, errs, bucket, object), lerr
|
|
||||||
}
|
|
||||||
defer objectLock.RUnlock()
|
|
||||||
|
|
||||||
errCount := 0
|
errCount := 0
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user