mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
xl: Avoid possible race during bulk Multi Delete (#7644)
errs was passed to many goroutines but they are all allowed to update errs if any error happens during deletion, which can cause a data race. This commit will avoid issuing bulk delete operations in parallel to avoid the warning race.
This commit is contained in:
parent
b3f22eac56
commit
9b4a81ee60
@ -803,30 +803,22 @@ func (xl xlObjects) doDeleteObjects(ctx context.Context, bucket string, objects
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize sync waitgroup.
|
||||
var wg = &sync.WaitGroup{}
|
||||
// Initialize list of errors.
|
||||
var opErrs = make([]error, len(disks))
|
||||
var delObjErrs = make([][]error, len(disks))
|
||||
|
||||
// Remove objects in bulk for each disk
|
||||
for index, disk := range disks {
|
||||
if disk == nil {
|
||||
opErrs[index] = errDiskNotFound
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(index int, disk StorageAPI) {
|
||||
defer wg.Done()
|
||||
delObjErrs[index], opErrs[index] = cleanupObjectsBulk(ctx, disk, minioMetaTmpBucket, tmpObjs, errs)
|
||||
if opErrs[index] == errVolumeNotFound {
|
||||
opErrs[index] = nil
|
||||
}
|
||||
}(index, disk)
|
||||
delObjErrs[index], opErrs[index] = cleanupObjectsBulk(ctx, disk, minioMetaTmpBucket, tmpObjs, errs)
|
||||
if opErrs[index] == errVolumeNotFound {
|
||||
opErrs[index] = nil
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all routines to finish.
|
||||
wg.Wait()
|
||||
|
||||
// Return errors if any during deletion
|
||||
if err := reduceWriteQuorumErrs(ctx, opErrs, objectOpIgnoredErrs, len(xl.getDisks())/2+1); err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user