Apache Lucene open-source search software
SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request cannot be found in 1 second.
Mark Robert Miller83e28ca6dd3b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3529f2ea3de..7b061f70804 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -114,6 +114,9 @@ Bug Fixes* SOLR-5461: Request proxying should only set con.setDoOutput(true) if therequest is a post. (Mark Miller)+* SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request+ cannot be found in 1 second. (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 f77a774ea39..6f1ab9f9c4a 100644--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java@@ -72,48 +72,56 @@ public class SolrCmdDistributor {List<Error> resubmitList = new ArrayList<Error>();for (Error err : errors) {- String oldNodeUrl = err.req.node.getUrl();-- // if there is a retry url, we want to retry...- boolean isRetry = err.req.node.checkRetry();- boolean doRetry = false;- int rspCode = err.statusCode;-- if (testing_errorHook != null) Diagnostics.call(testing_errorHook, err.e);-- // this can happen in certain situations such as shutdown- if (isRetry) {- if (rspCode == 404 || rspCode == 403 || rspCode == 503- || rspCode == 500) {- doRetry = true;- }+ try {+ String oldNodeUrl = err.req.node.getUrl();- // if its an ioexception, lets try again- if (err.e instanceof IOException) {- doRetry = true;- } else if (err.e instanceof SolrServerException) {- if (((SolrServerException) err.e).getRootCause() instanceof IOException) {+ // if there is a retry url, we want to retry...+ boolean isRetry = err.req.node.checkRetry();++ boolean doRetry = false;+ int rspCode = err.statusCode;++ if (testing_errorHook != null) Diagnostics.call(testing_errorHook,+ err.e);++ // this can happen in certain situations such as shutdown+ if (isRetry) {+ if (rspCode == 404 || rspCode == 403 || rspCode == 503+ || rspCode == 500) {doRetry = true;}- }- if (err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {- err.req.retries++;- SolrException.log(SolrCmdDistributor.log, "forwarding update to "- + oldNodeUrl + " failed - retrying ... retries: " + err.req.retries);- try {- Thread.sleep(500);- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- log.warn(null, e);+ // if its an ioexception, lets try again+ if (err.e instanceof IOException) {+ doRetry = true;+ } else if (err.e instanceof SolrServerException) {+ if (((SolrServerException) err.e).getRootCause() instanceof IOException) {+ doRetry = true;+ }+ }+ if (err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {+ err.req.retries++;++ SolrException.log(SolrCmdDistributor.log, "forwarding update to "+ + oldNodeUrl + " failed - retrying ... retries: "+ + err.req.retries);+ try {+ Thread.sleep(500);+ } catch (InterruptedException e) {+ Thread.currentThread().interrupt();+ log.warn(null, e);+ }++ resubmitList.add(err);+ } else {+ allErrors.add(err);}-- resubmitList.add(err);} else {allErrors.add(err);}- } else {- allErrors.add(err);+ } catch (Exception e) {+ // continue on+ log.error("Unexpected Error while doing request retries", e);}}@@ -353,10 +361,14 @@ public class SolrCmdDistributor {} catch (InterruptedException e) {Thread.currentThread().interrupt();return false;+ } catch (Exception e) {+ // we retry with same info+ log.warn(null, e);+ return true;}this.nodeProps = leaderProps;-+return true;}