Apache Lucene open-source search software
SOLR-5503: Retry 'forward to leader' requests less aggressively - rather than on IOException, ConnectException.
Mark Robert Miller8f94ae68deba
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 46b28142355..6eb7a008c78 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -151,6 +151,9 @@ Bug FixesHttpClients and ensure all http connection managers get shutdown.(Mark Miller)+* SOLR-5503: Retry 'forward to leader' requests less aggressively - rather+ than on IOException and status 500, ConnectException. (Mark Miller)+Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.javaindex 26ec0cbde42..ac124d3877a 100644--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java@@ -18,12 +18,14 @@ package org.apache.solr.update;*/import java.io.IOException;+import java.net.ConnectException;import java.util.ArrayList;import java.util.List;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.impl.HttpSolrServer;+import org.apache.solr.client.solrj.impl.HttpSolrServer.RemoteSolrException;import org.apache.solr.client.solrj.request.AbstractUpdateRequest;import org.apache.solr.client.solrj.request.UpdateRequest;import org.apache.solr.common.SolrException;@@ -98,11 +100,16 @@ public class SolrCmdDistributor {doRetry = true;}- // if its an ioexception, lets try again- if (err.e instanceof IOException) {+ // if its a connect exception, lets try again+ if (err.e instanceof ConnectException) {doRetry = true;} else if (err.e instanceof SolrServerException) {- if (((SolrServerException) err.e).getRootCause() instanceof IOException) {+ if (((SolrServerException) err.e).getRootCause() instanceof ConnectException) {+ doRetry = true;+ }+ } else if (err.e instanceof RemoteSolrException) {+ Exception cause = (RemoteSolrException) err.e.getCause();+ if (cause != null && cause instanceof ConnectException) {doRetry = true;}}diff --git a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.javaindex d2f5b612637..b881fb79655 100644--- a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java@@ -439,10 +439,10 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {long numFoundAfter = solrclient.query(new SolrQuery("*:*")).getResults().getNumFound();- // we will get java.net.SocketException: Network is unreachable and then retry- assertEquals(numFoundBefore + 1, numFoundAfter);+ // we will get java.net.SocketException: Network is unreachable and not retry+ assertEquals(numFoundBefore, numFoundAfter);- assertEquals(0, cmdDistrib.getErrors().size());+ assertEquals(1, cmdDistrib.getErrors().size());}@Override