oracleobjectstorage: retry 409 ConcurrentObjectUpdate errors - fixes #10194
This commit is contained in:
1 parent
3ca4fd99b6
commit
b3d0b38694
2 files changed
+35
No files matched your search
@@ -126,6 +126,10 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err
|
||||
if ociError.GetCode() == "RequestTimeout" {
|
||||
return true, err
|
||||
}
|
||||
// Parallel part uploads can collide on the same object
|
||||
if ociError.GetHTTPStatusCode() == http.StatusConflict && ociError.GetCode() == "ConcurrentObjectUpdate" {
|
||||
return true, err
|
||||
}
|
||||
}
|
||||
// Ok, not an oci error, check for generic failure conditions
|
||||
return fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(resp, retryErrorCodes), err
|
||||
|
||||
@@ -102,3 +102,34 @@ func TestGzipEncoding(t *testing.T) {
|
||||
assert.Equal(t, "", md5sum)
|
||||
})
|
||||
}
|
||||
|
||||
// serviceError is a minimal common.ServiceError for shouldRetry
|
||||
type serviceError struct {
|
||||
status int
|
||||
code string
|
||||
}
|
||||
|
||||
func (e serviceError) Error() string { return e.code }
|
||||
func (e serviceError) GetHTTPStatusCode() int { return e.status }
|
||||
func (e serviceError) GetMessage() string { return e.code }
|
||||
func (e serviceError) GetCode() string { return e.code }
|
||||
func (e serviceError) GetOpcRequestID() string { return "" }
|
||||
|
||||
func TestShouldRetryServiceError(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
for _, test := range []struct {
|
||||
status int
|
||||
code string
|
||||
want bool
|
||||
}{
|
||||
{http.StatusConflict, "ConcurrentObjectUpdate", true},
|
||||
{http.StatusConflict, "BucketAlreadyExists", false},
|
||||
{http.StatusRequestTimeout, "RequestTimeout", true},
|
||||
{http.StatusNotFound, "ObjectNotFound", false},
|
||||
} {
|
||||
err := serviceError{status: test.status, code: test.code}
|
||||
retry, gotErr := shouldRetry(ctx, nil, err)
|
||||
assert.Equal(t, test.want, retry, test.code)
|
||||
assert.Equal(t, error(err), gotErr)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user