Skip to content

Commit ee68227

Browse files
committed
google-cloud-nio: retry on 502 errors, and increase max depth when doing channel reopens
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 799710f commit ee68227

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.EOFException;
2222
import java.net.SocketException;
2323
import java.net.SocketTimeoutException;
24+
import java.net.UnknownHostException;
2425
import javax.net.ssl.SSLException;
2526

2627
/**
@@ -144,7 +145,7 @@ void sleepForAttempt(int attempt) {
144145
* @return true if exs is a retryable error, otherwise false
145146
*/
146147
private static boolean isRetryable(final StorageException exs) {
147-
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 503;
148+
return exs.isRetryable() || exs.getCode() == 500 || exs.getCode() == 502 || exs.getCode() == 503;
148149
}
149150

150151
/**
@@ -154,7 +155,7 @@ private static boolean isRetryable(final StorageException exs) {
154155
private static boolean isReopenable(final StorageException exs) {
155156
Throwable throwable = exs;
156157
// ensures finite iteration
157-
int maxDepth = 10;
158+
int maxDepth = 20;
158159
while (throwable != null && maxDepth-- > 0) {
159160
if ((throwable.getMessage() != null
160161
&& throwable.getMessage().contains("Connection closed prematurely"))

0 commit comments

Comments
 (0)