From 85a1956e5c0c0099bb6c87d6fc994f72a738f389 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 18 Jun 2020 10:25:07 -0700 Subject: [PATCH] Avoid duplicate object holding locks (#9867) Fixes #9866 --- cmd/erasure-zones.go | 7 ++++--- cmd/fs-v1.go | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/erasure-zones.go b/cmd/erasure-zones.go index 2ce3b8e45..ba01458dc 100644 --- a/cmd/erasure-zones.go +++ b/cmd/erasure-zones.go @@ -26,6 +26,7 @@ import ( "sync" "time" + "github.com/minio/minio-go/v6/pkg/set" "github.com/minio/minio-go/v6/pkg/tags" "github.com/minio/minio/cmd/config/storageclass" 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) { derrs := make([]error, len(objects)) dobjects := make([]DeletedObject, len(objects)) - objNames := make([]string, len(objects)) + objSets := set.NewStringSet() for i := range derrs { 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' - multiDeleteLock := z.NewNSLock(ctx, bucket, objNames...) + multiDeleteLock := z.NewNSLock(ctx, bucket, objSets.ToSlice()...) if err := multiDeleteLock.GetLock(globalOperationTimeout); err != nil { for i := range derrs { derrs[i] = err diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 04b9d698f..e7f200a34 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -1181,7 +1181,11 @@ func (fs *FSObjects) DeleteObjects(ctx context.Context, bucket string, objects [ dobjects := make([]DeletedObject, len(objects)) for idx, object := range objects { if object.VersionID != "" { - errs[idx] = NotImplemented{} + errs[idx] = VersionNotFound{ + Bucket: bucket, + Object: object.ObjectName, + VersionID: object.VersionID, + } continue } _, errs[idx] = fs.DeleteObject(ctx, bucket, object.ObjectName, opts)