Skip to content

Commit

Permalink
google-cloud-nio: retry on 502 errors, and increase max depth when do…
Browse files Browse the repository at this point in the history
…ing channel reopens (googleapis#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.
  • Loading branch information
droazen authored and pongad committed Sep 4, 2018
1 parent 1f12a83 commit d7a135a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void sleepForAttempt(int attempt) {
* @return true if exs is a retryable error, otherwise false
*/
private static boolean isRetryable(final StorageException exs) {
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 503;
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 502 || exs.getCode() == 503;
}

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

0 comments on commit d7a135a

Please sign in to comment.