Skip to content

Commit

Permalink
{miniogw, testsuite}: run deletion within DeleteObjects concurrently
Browse files Browse the repository at this point in the history
This changes DeleteObjects from executing deletion sequentially. How
many deletions to run concurrently is controlled with a new
configuration parameter (default=100).

Updates storj/storj-private#252

Change-Id: Ie12ea00c2d0e806be9b7c1d0769c21ddf60b0c97
  • Loading branch information
amwolff committed May 11, 2023
1 parent d3c6ead commit 366e491
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions miniogw/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ type S3CompatibilityConfig struct {
FullyCompatibleListing bool `help:"make ListObjects(V2) fully S3-compatible (specifically: always return lexicographically ordered results) but slow" default:"false"`
DisableCopyObject bool `help:"return 501 (Not Implemented) for CopyObject calls" default:"false"`
MinPartSize int64 `help:"minimum part size for multipart uploads" default:"5242880"` // 5 MiB
DeleteObjectsConcurrency int `help:"how many objects to delete in parallel with DeleteObjects" default:"100"`
}
22 changes: 16 additions & 6 deletions miniogw/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/zeebo/errs"

"storj.io/common/memory"
"storj.io/common/sync2"
minio "storj.io/minio/cmd"
"storj.io/minio/cmd/config/storageclass"
xhttp "storj.io/minio/cmd/http"
Expand Down Expand Up @@ -998,14 +999,23 @@ func (layer *gatewayLayer) DeleteObject(ctx context.Context, bucket, objectPath
func (layer *gatewayLayer) DeleteObjects(ctx context.Context, bucket string, objects []minio.ObjectToDelete, opts minio.ObjectOptions) ([]minio.DeletedObject, []error) {
// TODO: implement multiple object deletion in libuplink API
deleted, errs := make([]minio.DeletedObject, len(objects)), make([]error, len(objects))

limiter := sync2.NewLimiter(layer.compatibilityConfig.DeleteObjectsConcurrency)

for i, object := range objects {
_, deleteErr := layer.DeleteObject(ctx, bucket, object.ObjectName, opts)
if deleteErr != nil && !errors.As(deleteErr, &minio.ObjectNotFound{}) {
errs[i] = ConvertError(deleteErr, bucket, object.ObjectName)
continue
}
deleted[i].ObjectName = object.ObjectName
i, object := i, object
limiter.Go(ctx, func() {
_, err := layer.DeleteObject(ctx, bucket, object.ObjectName, opts)
if err != nil && !errors.As(err, &minio.ObjectNotFound{}) {
errs[i] = ConvertError(err, bucket, object.ObjectName)
return
}
deleted[i].ObjectName = object.ObjectName
})
}

limiter.Wait()

return deleted, errs
}

Expand Down
1 change: 1 addition & 0 deletions testsuite/miniogw/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4022,6 +4022,7 @@ func runTestWithPathCipher(t *testing.T, pathCipher storj.CipherSuite, test func
MaxKeysLimit: maxKeysLimit,
MaxKeysExhaustiveLimit: 100000,
MaxUploadsLimit: maxUploadsLimit,
DeleteObjectsConcurrency: 100,
}

layer, err := miniogw.NewStorjGateway(s3Compatibility).NewGatewayLayer(auth.Credentials{})
Expand Down

1 comment on commit 366e491

@storjrobot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Storj Community Forum (official). There might be relevant details there:

https://forum.storj.io/t/error-when-trying-to-delete-more-then-1-file-using-s3/22718/4

Please sign in to comment.