This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new 09273605e32 SOLR-17897: CloudSolrClient: treat UnknownHostException as
retry-able (#3791)
09273605e32 is described below
commit 09273605e32820bf0f04ae1e392e0a47f35009e7
Author: David Smiley <[email protected]>
AuthorDate: Thu Oct 23 11:12:01 2025 -0400
SOLR-17897: CloudSolrClient: treat UnknownHostException as retry-able
(#3791)
CloudSolrClient now recognizes UnknownHostException as a case to refetch
the cluster state and retry. A "commError".
---
solr/CHANGES.txt | 3 +++
.../apache/solr/client/solrj/impl/CloudHttp2SolrClient.java | 5 -----
.../apache/solr/client/solrj/impl/CloudLegacySolrClient.java | 3 ++-
.../org/apache/solr/client/solrj/impl/CloudSolrClient.java | 12 ++++++------
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e39676322da..9ed5cad24c6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -342,6 +342,9 @@ Improvements
* SOLR-17921: SolrJ CloudSolrClient configured with a Solr URL (not ZK) now
refreshes liveNodes in the background.
This will reduce spikes in request latency when the cached liveNodes have
expired. (Houston Putman, David Smiley)
+* SOLR-17897: CloudSolrClient now recognizes UnknownHostException as a case to
refetch the cluster
+ state and retry. (David Smiley)
+
Optimizations
---------------------
(No changes)
diff --git
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
index 4b3ac046ac2..0bb4d3eb67a 100644
---
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
+++
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
@@ -182,11 +182,6 @@ public class CloudHttp2SolrClient extends CloudSolrClient {
return myClient;
}
- @Override
- protected boolean wasCommError(Throwable rootCause) {
- return false;
- }
-
/** Constructs {@link CloudHttp2SolrClient} instances from provided
configuration. */
public static class Builder {
protected Collection<String> zkHosts = new ArrayList<>();
diff --git
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
index e8aecc8a88b..2c660c63228 100644
---
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
+++
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
@@ -140,7 +140,8 @@ public class CloudLegacySolrClient extends CloudSolrClient {
@Override
protected boolean wasCommError(Throwable rootCause) {
- return rootCause instanceof ConnectTimeoutException
+ return super.wasCommError(rootCause)
+ || rootCause instanceof ConnectTimeoutException
|| rootCause instanceof NoHttpResponseException;
}
diff --git
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index ebe1fddf0ee..ac12e5b5722 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -21,8 +21,8 @@ import static org.apache.solr.common.params.CommonParams.ID;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.net.ConnectException;
import java.net.SocketException;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -221,7 +221,10 @@ public abstract class CloudSolrClient extends SolrClient {
return getClusterStateProvider().getClusterState();
}
- protected abstract boolean wasCommError(Throwable t);
+ /** Is this a communication error? We will retry if so. */
+ protected boolean wasCommError(Throwable t) {
+ return t instanceof SocketException || t instanceof UnknownHostException;
+ }
@Override
public void close() throws IOException {
@@ -813,10 +816,7 @@ public abstract class CloudSolrClient extends SolrClient {
? ((SolrException) rootCause).code()
: SolrException.ErrorCode.UNKNOWN.code;
- boolean wasCommError =
- (rootCause instanceof ConnectException
- || rootCause instanceof SocketException
- || wasCommError(rootCause));
+ final boolean wasCommError = wasCommError(rootCause);
if (wasCommError
|| (exc instanceof RouteException