This is an automated email from the ASF dual-hosted git repository.
cwylie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new c3c66de2d56 add ServiceClientImpl retry on 401 (#18771)
c3c66de2d56 is described below
commit c3c66de2d56ccf8d2593cc0b340844f6f5d7c34d
Author: Clint Wylie <[email protected]>
AuthorDate: Wed Dec 3 15:42:44 2025 -0800
add ServiceClientImpl retry on 401 (#18771)
---
.../java/org/apache/druid/rpc/StandardRetryPolicy.java | 3 ++-
.../org/apache/druid/rpc/ServiceClientImplTest.java | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/org/apache/druid/rpc/StandardRetryPolicy.java
b/server/src/main/java/org/apache/druid/rpc/StandardRetryPolicy.java
index 71097ef6d89..07d753c7f3b 100644
--- a/server/src/main/java/org/apache/druid/rpc/StandardRetryPolicy.java
+++ b/server/src/main/java/org/apache/druid/rpc/StandardRetryPolicy.java
@@ -141,7 +141,8 @@ public class StandardRetryPolicy implements
ServiceRetryPolicy
return code == HttpResponseStatus.BAD_GATEWAY.getCode()
|| code == HttpResponseStatus.SERVICE_UNAVAILABLE.getCode()
|| code == HttpResponseStatus.GATEWAY_TIMEOUT.getCode()
-
+ // 401 can happen from things like expiration and might be retryable
+ || code == HttpResponseStatus.UNAUTHORIZED.getCode()
// Technically shouldn't retry this last one, but servers sometimes
return HTTP 500 for retryable errors.
|| code == HttpResponseStatus.INTERNAL_SERVER_ERROR.getCode();
}
diff --git
a/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
b/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
index 7346edd5cf6..0b2bb7fe264 100644
--- a/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
+++ b/server/src/test/java/org/apache/druid/rpc/ServiceClientImplTest.java
@@ -715,6 +715,23 @@ public class ServiceClientImplTest
);
}
+ @Test
+ public void test_request_authErrorRetry() throws Exception
+ {
+ final RequestBuilder requestBuilder = new RequestBuilder(HttpMethod.GET,
"/foo");
+ final ImmutableMap<String, String> expectedResponseObject =
ImmutableMap.of("foo", "bar");
+
+ // Unauthorized response from SERVER1, then OK response.
+ stubLocatorCall(locations(SERVER1, SERVER2));
+ expectHttpCall(requestBuilder, SERVER1)
+ .thenReturn(errorResponse(HttpResponseStatus.UNAUTHORIZED, null,
"unauthorized"))
+ .thenReturn(valueResponse(expectedResponseObject));
+
+ serviceClient = makeServiceClient(StandardRetryPolicy.unlimited());
+ final Map<String, String> response = doRequest(serviceClient,
requestBuilder);
+ Assert.assertEquals(expectedResponseObject, response);
+ }
+
private void stubLocatorCall(final ServiceLocations locations)
{
stubLocatorCall(Futures.immediateFuture(locations));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]