From 6e758e1a67f0f8611b57cb7b952d4f3debbd48d5 Mon Sep 17 00:00:00 2001 From: Narasimha Kulkarni <63087328+nakulkar-msft@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:41:20 +0530 Subject: [PATCH] Retry custom request --- common/version.go | 2 +- ste/xferRetrypolicy.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index 2b8cbfc78..b85259795 100644 --- a/common/version.go +++ b/common/version.go @@ -1,6 +1,6 @@ package common -const AzcopyVersion = "10.19.0" +const AzcopyVersion = "10.19.0-preview" const UserAgent = "AzCopy/" + AzcopyVersion const S3ImportUserAgent = "S3Import " + UserAgent const GCPImportUserAgent = "GCPImport " + UserAgent diff --git a/ste/xferRetrypolicy.go b/ste/xferRetrypolicy.go index b715ef01e..f8a34fa9e 100644 --- a/ste/xferRetrypolicy.go +++ b/ste/xferRetrypolicy.go @@ -6,6 +6,7 @@ import ( "math/rand" "net" "net/http" + "os" "strconv" "time" @@ -60,6 +61,8 @@ type XferRetryOptions struct { // NOTE: Before setting this field, make sure you understand the issues around reading stale & potentially-inconsistent // data at this webpage: https://docs.microsoft.com/en-us/azure/storage/common/storage-designing-ha-apps-with-ragrs RetryReadsFromSecondaryHost string // Comment this our for non-Blob SDKs + + RetryHTTPErrorConflict bool } func (o XferRetryOptions) retryReadsFromSecondaryHost() string { @@ -220,6 +223,12 @@ func NewBFSXferRetryPolicyFactory(o XferRetryOptions) pipeline.Factory { switch { case err == nil: action = "NoRetry: successful HTTP request" // no error + case response.Response() != nil && response.Response().StatusCode == http.StatusConflict: + if o.RetryHTTPErrorConflict && os.Getenv("AZCOPY_DISABLE_CUSTOM_RETRY") == "" { + action = "Retry: Custom request" + } else { + action = "NoRetry" + } case !tryingPrimary && response != nil && response.Response() != nil && response.Response().StatusCode == http.StatusNotFound: // If attempt was against the secondary & it returned a StatusNotFound (404), then