This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 0768b7973bd SOLR-17897: CloudSolrClient: treat UnknownHostException as
retry-able (#3791)
0768b7973bd is described below
commit 0768b7973bd2870fb646b5807d2990cf0d741cde
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".
(cherry picked from commit d52761aa97933bdaf65202208efc111bcd98a1cb)
---
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 c4278bae571..46a28df26cd 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -29,6 +29,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 90e028e15e1..2ddc6479769 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
@@ -162,11 +162,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 224757200ff..75b25a3c7fe 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 ed7d9977364..8dbfe1c9aab 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
@@ -22,8 +22,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;
@@ -316,7 +316,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 {
@@ -948,10 +951,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