Skip to content

Commit

Permalink
google-cloud-nio: retry on 502 errors, and do a channel reopen on Unk…
Browse files Browse the repository at this point in the history
…nownHostException

We've frequently encountered both of these errors transiently in the wild (see
broadinstitute/gatk#4888 and
broadinstitute/gatk#5094

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 committed Aug 14, 2018
1 parent 799710f commit 256a6a3
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.EOFException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import javax.net.ssl.SSLException;

/**
Expand Down Expand Up @@ -144,7 +145,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,14 +155,15 @@ 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"))
|| throwable instanceof SSLException
|| throwable instanceof EOFException
|| throwable instanceof SocketException
|| throwable instanceof SocketTimeoutException) {
|| throwable instanceof SocketTimeoutException
|| throwable instanceof UnknownHostException) {
return true;
}
throwable = throwable.getCause();
Expand Down

0 comments on commit 256a6a3

Please sign in to comment.