Skip to content

Commit d7a135a

Browse files
droazenpongad
authored andcommitted
google-cloud-nio: retry on 502 errors, and increase max depth when doing channel reopens (#3557)
We've frequently encountered transient 502 errors in the wild when using google-cloud-nio (see broadinstitute/gatk#4888), implying that this error should be added to the list of retryable errors. I also increased the maximum depth when inspecting nested exceptions looking for reopenable errors from 10 to 20, as we've seen chains of exceptions that come very close to the current limit of 10.
1 parent 1f12a83 commit d7a135a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageRetryHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void sleepForAttempt(int attempt) {
144144
* @return true if exs is a retryable error, otherwise false
145145
*/
146146
private static boolean isRetryable(final StorageException exs) {
147-
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 503;
147+
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 502 || exs.getCode() == 503;
148148
}
149149

150150
/**
@@ -154,7 +154,7 @@ private static boolean isRetryable(final StorageException exs) {
154154
private static boolean isReopenable(final StorageException exs) {
155155
Throwable throwable = exs;
156156
// ensures finite iteration
157-
int maxDepth = 10;
157+
int maxDepth = 20;
158158
while (throwable != null && maxDepth-- > 0) {
159159
if ((throwable.getMessage() != null
160160
&& throwable.getMessage().contains("Connection closed prematurely"))

0 commit comments

Comments
 (0)