This is an automated email from the ASF dual-hosted git repository.
etudenhoefner pushed a commit to branch 1.5.x
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/1.5.x by this push:
new b2a4fda8a8 Core: Mark 502 and 504 failures as retryable to the
exponential retry strategy (#10113)
b2a4fda8a8 is described below
commit b2a4fda8a80571a6a63f301ff67c63ecc0380cf7
Author: Amogh Jahagirdar <[email protected]>
AuthorDate: Wed Apr 10 00:25:35 2024 -0600
Core: Mark 502 and 504 failures as retryable to the exponential retry
strategy (#10113)
---
.../iceberg/rest/ExponentialHttpRequestRetryStrategy.java | 8 +++++++-
.../rest/TestExponentialHttpRequestRetryStrategy.java | 12 ++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/iceberg/rest/ExponentialHttpRequestRetryStrategy.java
b/core/src/main/java/org/apache/iceberg/rest/ExponentialHttpRequestRetryStrategy.java
index 9d8f5424f5..aadb97bc71 100644
---
a/core/src/main/java/org/apache/iceberg/rest/ExponentialHttpRequestRetryStrategy.java
+++
b/core/src/main/java/org/apache/iceberg/rest/ExponentialHttpRequestRetryStrategy.java
@@ -60,7 +60,9 @@ import
org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
*
* <ul>
* <li>SC_TOO_MANY_REQUESTS (429)
+ * <li>SC_BAD_GATEWAY (502)
* <li>SC_SERVICE_UNAVAILABLE (503)
+ * <li>SC_GATEWAY_TIMEOUT (504)
* </ul>
*
* Most code and behavior is taken from {@link
@@ -77,7 +79,11 @@ class ExponentialHttpRequestRetryStrategy implements
HttpRequestRetryStrategy {
maximumRetries > 0, "Cannot set retries to %s, the value must be
positive", maximumRetries);
this.maxRetries = maximumRetries;
this.retriableCodes =
- ImmutableSet.of(HttpStatus.SC_TOO_MANY_REQUESTS,
HttpStatus.SC_SERVICE_UNAVAILABLE);
+ ImmutableSet.of(
+ HttpStatus.SC_TOO_MANY_REQUESTS,
+ HttpStatus.SC_SERVICE_UNAVAILABLE,
+ HttpStatus.SC_BAD_GATEWAY,
+ HttpStatus.SC_GATEWAY_TIMEOUT);
this.nonRetriableExceptions =
ImmutableSet.of(
InterruptedIOException.class,
diff --git
a/core/src/test/java/org/apache/iceberg/rest/TestExponentialHttpRequestRetryStrategy.java
b/core/src/test/java/org/apache/iceberg/rest/TestExponentialHttpRequestRetryStrategy.java
index e63bdfd067..7d8c58701a 100644
---
a/core/src/test/java/org/apache/iceberg/rest/TestExponentialHttpRequestRetryStrategy.java
+++
b/core/src/test/java/org/apache/iceberg/rest/TestExponentialHttpRequestRetryStrategy.java
@@ -196,4 +196,16 @@ public class TestExponentialHttpRequestRetryStrategy {
assertThat(retryStrategy.getRetryInterval(response, 3,
null).toMilliseconds())
.isBetween(4000L, 5000L);
}
+
+ @Test
+ public void testRetryBadGateway() {
+ BasicHttpResponse response502 = new BasicHttpResponse(502, "Bad gateway
failure");
+ assertThat(retryStrategy.retryRequest(response502, 3, null)).isTrue();
+ }
+
+ @Test
+ public void testRetryGatewayTimeout() {
+ BasicHttpResponse response504 = new BasicHttpResponse(504, "Gateway
timeout");
+ assertThat(retryStrategy.retryRequest(response504, 3, null)).isTrue();
+ }
}