From cc3f139d1f3b798f2aa94b331ccda3f7cc64d173 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 11 Jan 2022 22:32:29 -0800 Subject: [PATCH] replication: attempt abort multipart-upload at max 3 times on remote (#14087) this is mainly an attempt to relinquish space on the remote site, if this still doesn't do it we give and let the admin know with a log message. --- cmd/bucket-replication.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index ebaa67be2..cd0d91d78 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -28,6 +28,7 @@ import ( "sync" "time" + "github.com/dustin/go-humanize" "github.com/minio/madmin-go" "github.com/minio/minio-go/v7" miniogo "github.com/minio/minio-go/v7" @@ -1184,9 +1185,17 @@ func replicateObjectWithMultipart(ctx context.Context, c *miniogo.Core, bucket, defer func() { if err != nil { // block and abort remote upload upon failure. - if aerr := c.AbortMultipartUpload(ctx, bucket, object, uploadID); aerr != nil { - aerr = fmt.Errorf("Unable to cleanup failed multipart replication %s on remote %s/%s: %w", uploadID, bucket, object, aerr) - logger.LogIf(ctx, aerr) + attempts := 1 + for attempts <= 3 { + aerr := c.AbortMultipartUpload(ctx, bucket, object, uploadID) + if aerr == nil { + return + } + logger.LogIf(ctx, + fmt.Errorf("Trying %s: Unable to cleanup failed multipart replication %s on remote %s/%s: %w - this may consume space on remote cluster", + humanize.Ordinal(attempts), uploadID, bucket, object, aerr)) + attempts++ + time.Sleep(time.Second) } } }()