diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 2e338275ef1..953b2d4cf0b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -178,7 +178,10 @@ Bug Fixes * SOLR-8416: The collections create API should return after all replicas are active. (Michael Sun, Mark Miller, Alexey Serba) - + +* SOLR-8701: CloudSolrClient decides that there are no healthy nodes to handle a request too early. + (Mark Miller) + Optimizations ---------------------- * SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been 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 0973475e71c..59b37c5cce9 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 @@ -1077,12 +1077,6 @@ public class CloudSolrClient extends SolrClient { theUrlList = new ArrayList<>(urlList.size()); theUrlList.addAll(urlList); } - if(theUrlList.isEmpty()) { - for (String s : collectionNames) { - if(s!=null) collectionStateCache.remove(s); - } - throw new SolrException(SolrException.ErrorCode.INVALID_STATE, "Could not find a healthy node to handle the request."); - } Collections.shuffle(theUrlList, rand); if (sendToLeaders) { @@ -1093,6 +1087,13 @@ public class CloudSolrClient extends SolrClient { theUrlList.addAll(theReplicas); } + if (theUrlList.isEmpty()) { + for (String s : collectionNames) { + if (s != null) collectionStateCache.remove(s); + } + throw new SolrException(SolrException.ErrorCode.INVALID_STATE, + "Could not find a healthy node to handle the request."); + } } LBHttpSolrClient.Req req = new LBHttpSolrClient.Req(request, theUrlList);