Skip to content

Commit

Permalink
Increased default maxRetries for download to help Connection reset by…
Browse files Browse the repository at this point in the history
… peer issues (#22457)
  • Loading branch information
gapra-msft authored Jun 23, 2021
1 parent 7335011 commit 8f808b2
Show file tree
Hide file tree
Showing 12 changed files with 677 additions and 111 deletions.
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 12.13.0-beta.1 (Unreleased)
- Added support to get a blob client that uses an encryption scope and customer provided key.
- Updated DownloadRetryOptions.maxRetryRequests to default downloads to retry 5 times.

## 12.12.0 (2021-06-09)
- GA release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class DownloadRetryOptions {
issued and returned. This is in contrast to the retry policy options, which includes the initial try in its count,
thus the difference in verbiage.
*/
private int maxRetryRequests = 0;
private int maxRetryRequests = 5;

/**
* Specifies the maximum number of additional HTTP Get requests that will be made while reading the data from a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.azure.storage.common.implementation.Constants
import com.azure.storage.common.policy.RequestRetryOptions
import com.azure.storage.common.test.shared.StorageSpec
import com.azure.storage.common.test.shared.TestAccount
import com.azure.storage.common.test.shared.policy.MockDownloadHttpResponse
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import spock.lang.Timeout
Expand Down Expand Up @@ -684,60 +685,6 @@ class APISpec extends StorageSpec {
}
}

/*
This is for stubbing responses that will actually go through the pipeline and autorest code. Autorest does not seem
to play too nicely with mocked objects and the complex reflection stuff on both ends made it more difficult to work
with than was worth it. Because this type is just for BlobDownload, we don't need to accept a header type.
*/

class MockDownloadHttpResponse extends HttpResponse {
private final int statusCode
private final HttpHeaders headers
private final Flux<ByteBuffer> body

MockDownloadHttpResponse(HttpResponse response, int statusCode, Flux<ByteBuffer> body) {
super(response.getRequest())
this.statusCode = statusCode
this.headers = response.getHeaders()
this.body = body
}

@Override
int getStatusCode() {
return statusCode
}

@Override
String getHeaderValue(String s) {
return headers.getValue(s)
}

@Override
HttpHeaders getHeaders() {
return headers
}

@Override
Flux<ByteBuffer> getBody() {
return body
}

@Override
Mono<byte[]> getBodyAsByteArray() {
return Mono.error(new IOException())
}

@Override
Mono<String> getBodyAsString() {
return Mono.error(new IOException())
}

@Override
Mono<String> getBodyAsString(Charset charset) {
return Mono.error(new IOException())
}
}

/**
* Injects one retry-able IOException failure per url.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

package com.azure.storage.blob

import com.azure.core.http.HttpPipelineCallContext
import com.azure.core.http.HttpPipelineNextPolicy
import com.azure.core.http.HttpResponse
import com.azure.core.http.RequestConditions
import com.azure.core.http.policy.HttpPipelinePolicy
import com.azure.core.util.BinaryData
import com.azure.core.util.CoreUtils
import com.azure.core.util.polling.LongRunningOperationStatus
Expand Down Expand Up @@ -45,8 +49,11 @@ import com.azure.storage.common.implementation.Constants
import com.azure.storage.common.test.shared.extensions.LiveOnly
import com.azure.storage.common.test.shared.extensions.PlaybackOnly
import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion
import com.azure.storage.common.test.shared.policy.MockFailureResponsePolicy
import reactor.core.Exceptions
import reactor.core.publisher.Flux
import reactor.core.publisher.Hooks
import reactor.core.publisher.Mono
import reactor.test.StepVerifier
import spock.lang.IgnoreIf
import spock.lang.Requires
Expand Down Expand Up @@ -638,6 +645,19 @@ class BlobAPITest extends APISpec {
contentMD5 == MessageDigest.getInstance("MD5").digest(data.defaultText.substring(0, 3).getBytes())
}

def "Download retry default"() {
setup:
def failureBlobClient = getBlobClient(env.primaryAccount.credential, bc.getBlobUrl(), new MockFailureResponsePolicy(5))

when:
def outStream = new ByteArrayOutputStream()
failureBlobClient.download(outStream)
String bodyStr = outStream.toString()

then:
bodyStr == data.defaultText
}

def "Download error"() {
setup:
bc = cc.getBlobClient(generateBlobName())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0?restype=container",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "617bc120-62e1-4c40-beb5-d80cc916f967"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-08-04",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D935CF2E7D5705",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "1fc13a72-801e-007a-13b8-6750e0000000",
"x-ms-client-request-id" : "617bc120-62e1-4c40-beb5-d80cc916f967",
"Date" : "Tue, 22 Jun 2021 22:43:39 GMT"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "7b80da98-e055-4f4b-acc7-8fb09c302f6d",
"Content-Type" : "application/octet-stream"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-08-04",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-content-crc64" : "6RYQPwaVsyQ=",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-server-encrypted" : "true",
"Date" : "Tue, 22 Jun 2021 22:43:40 GMT",
"Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13ad3-801e-007a-68b8-6750e0000000",
"x-ms-client-request-id" : "7b80da98-e055-4f4b-acc7-8fb09c302f6d"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "aa84fdbf-d57a-49e6-9256-66126dc08e6a"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"retry-after" : "0",
"StatusCode" : "200",
"Date" : "Tue, 22 Jun 2021 22:43:40 GMT",
"Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13b04-801e-007a-14b8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "aa84fdbf-d57a-49e6-9256-66126dc08e6a",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "19fc7bdc-6436-4f6d-9a06-c1f24af21290"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"Content-Range" : "bytes 0-6/7",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"x-ms-blob-content-md5" : "wh+Wm18D0z1D4E+PE252gg==",
"retry-after" : "0",
"StatusCode" : "206",
"Date" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13b4d-801e-007a-59b8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "19fc7bdc-6436-4f6d-9a06-c1f24af21290",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "16e79460-293c-4001-9a92-838ddf6d9243"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"Content-Range" : "bytes 0-6/7",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"x-ms-blob-content-md5" : "wh+Wm18D0z1D4E+PE252gg==",
"retry-after" : "0",
"StatusCode" : "206",
"Date" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13b64-801e-007a-6db8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "16e79460-293c-4001-9a92-838ddf6d9243",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "f6bd90f5-5b7d-4933-a326-1f24abadc71b"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"Content-Range" : "bytes 0-6/7",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"x-ms-blob-content-md5" : "wh+Wm18D0z1D4E+PE252gg==",
"retry-after" : "0",
"StatusCode" : "206",
"Date" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13b7b-801e-007a-01b8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "f6bd90f5-5b7d-4933-a326-1f24abadc71b",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "45bc9f54-52ae-4d76-9d80-01f6842cb2a7"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"Content-Range" : "bytes 0-6/7",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"x-ms-blob-content-md5" : "wh+Wm18D0z1D4E+PE252gg==",
"retry-after" : "0",
"StatusCode" : "206",
"Date" : "Tue, 22 Jun 2021 22:43:41 GMT",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13b93-801e-007a-15b8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "45bc9f54-52ae-4d76-9d80-01f6842cb2a7",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0/8b0ad08318b0ad083462324176c17ac6dff534c3e8a3",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "c0fef5ce-c90f-45cd-a308-50d33e40f8d9"
},
"Response" : {
"x-ms-is-current-version" : "true",
"content-length" : "7",
"x-ms-version" : "2020-08-04",
"x-ms-lease-status" : "unlocked",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"Content-Range" : "bytes 0-6/7",
"x-ms-lease-state" : "available",
"Last-Modified" : "Tue, 22 Jun 2021 22:43:40 GMT",
"x-ms-version-id" : "2021-06-22T22:43:40.8615080Z",
"x-ms-blob-content-md5" : "wh+Wm18D0z1D4E+PE252gg==",
"retry-after" : "0",
"StatusCode" : "206",
"Date" : "Tue, 22 Jun 2021 22:43:41 GMT",
"x-ms-blob-type" : "BlockBlob",
"Accept-Ranges" : "bytes",
"x-ms-server-encrypted" : "true",
"x-ms-creation-time" : "Tue, 22 Jun 2021 22:43:40 GMT",
"eTag" : "0x8D935CF2EC22AA8",
"x-ms-request-id" : "1fc13ba5-801e-007a-26b8-6750e0000000",
"Body" : "ZGVmYXVsdA==",
"x-ms-client-request-id" : "c0fef5ce-c90f-45cd-a308-50d33e40f8d9",
"Content-Type" : "application/octet-stream"
},
"Exception" : null
} ],
"variables" : [ "8b0ad08308b0ad083462453172cc2f9ec9f78478f9a0", "8b0ad08318b0ad083462324176c17ac6dff534c3e8a3" ]
}
Loading

0 comments on commit 8f808b2

Please sign in to comment.