You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/12/28 23:25:59 UTC

svn commit: r1553945 - in /lucene/dev/branches/lucene_solr_4_6: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java

Author: markrmiller
Date: Sat Dec 28 22:25:59 2013
New Revision: 1553945

URL: http://svn.apache.org/r1553945
Log:
SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request cannot be found in 1 second.

Modified:
    lucene/dev/branches/lucene_solr_4_6/   (props changed)
    lucene/dev/branches/lucene_solr_4_6/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_6/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java

Modified: lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt?rev=1553945&r1=1553944&r2=1553945&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt Sat Dec 28 22:25:59 2013
@@ -47,6 +47,9 @@ Bug Fixes
 * SOLR-5445: Proxied responses should propagate all headers rather than the 
   first one for each key. (Patrick Hunt, Mark Miller) 
 
+* SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request 
+  cannot be found in 1 second. (Mark Miller)
+
 ==================  4.6.0 ==================
 
 Versions of Major Components

Modified: lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java?rev=1553945&r1=1553944&r2=1553945&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java (original)
+++ lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java Sat Dec 28 22:25:59 2013
@@ -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;
     }