Avoid duplicate object holding locks (#9867)

Fixes #9866
master
Harshavardhana 5 years ago committed by GitHub
parent 72743d1590
commit 85a1956e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      cmd/erasure-zones.go
  2. 6
      cmd/fs-v1.go

@ -26,6 +26,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/minio/minio-go/v6/pkg/set"
"github.com/minio/minio-go/v6/pkg/tags" "github.com/minio/minio-go/v6/pkg/tags"
"github.com/minio/minio/cmd/config/storageclass" "github.com/minio/minio/cmd/config/storageclass"
xhttp "github.com/minio/minio/cmd/http" xhttp "github.com/minio/minio/cmd/http"
@ -542,14 +543,14 @@ func (z *erasureZones) DeleteObject(ctx context.Context, bucket string, object s
func (z *erasureZones) DeleteObjects(ctx context.Context, bucket string, objects []ObjectToDelete, opts ObjectOptions) ([]DeletedObject, []error) { func (z *erasureZones) DeleteObjects(ctx context.Context, bucket string, objects []ObjectToDelete, opts ObjectOptions) ([]DeletedObject, []error) {
derrs := make([]error, len(objects)) derrs := make([]error, len(objects))
dobjects := make([]DeletedObject, len(objects)) dobjects := make([]DeletedObject, len(objects))
objNames := make([]string, len(objects)) objSets := set.NewStringSet()
for i := range derrs { for i := range derrs {
derrs[i] = checkDelObjArgs(ctx, bucket, objects[i].ObjectName) derrs[i] = checkDelObjArgs(ctx, bucket, objects[i].ObjectName)
objNames[i] = objects[i].ObjectName objSets.Add(objects[i].ObjectName)
} }
// Acquire a bulk write lock across 'objects' // Acquire a bulk write lock across 'objects'
multiDeleteLock := z.NewNSLock(ctx, bucket, objNames...) multiDeleteLock := z.NewNSLock(ctx, bucket, objSets.ToSlice()...)
if err := multiDeleteLock.GetLock(globalOperationTimeout); err != nil { if err := multiDeleteLock.GetLock(globalOperationTimeout); err != nil {
for i := range derrs { for i := range derrs {
derrs[i] = err derrs[i] = err

@ -1181,7 +1181,11 @@ func (fs *FSObjects) DeleteObjects(ctx context.Context, bucket string, objects [
dobjects := make([]DeletedObject, len(objects)) dobjects := make([]DeletedObject, len(objects))
for idx, object := range objects { for idx, object := range objects {
if object.VersionID != "" { if object.VersionID != "" {
errs[idx] = NotImplemented{} errs[idx] = VersionNotFound{
Bucket: bucket,
Object: object.ObjectName,
VersionID: object.VersionID,
}
continue continue
} }
_, errs[idx] = fs.DeleteObject(ctx, bucket, object.ObjectName, opts) _, errs[idx] = fs.DeleteObject(ctx, bucket, object.ObjectName, opts)

Loading…
Cancel
Save