You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2016/04/21 20:57:48 UTC

[2/3] lucene-solr:branch_5_5: SOLR-8633: DistributedUpdateProcess processCommit/deleteByQuery call finish on DUP and SolrCmdDistributor, which violates the lifecycle and can cause bugs.

SOLR-8633: DistributedUpdateProcess processCommit/deleteByQuery call finish on DUP and SolrCmdDistributor, which violates the lifecycle and can cause bugs.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e603565d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e603565d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e603565d

Branch: refs/heads/branch_5_5
Commit: e603565d4757625cc90d9db77a7ee240c20f93ed
Parents: 0e69a56
Author: markrmiller <ma...@apache.org>
Authored: Fri Feb 19 14:59:46 2016 -0500
Committer: anshum <an...@apache.org>
Committed: Thu Apr 21 11:28:52 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/solr/update/SolrCmdDistributor.java   |  8 ++++++--
 .../solr/update/processor/DistributedUpdateProcessor.java | 10 ++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e603565d/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index 0244b0e..d9b6478 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -55,7 +55,8 @@ public class SolrCmdDistributor {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   
   private StreamingSolrClients clients;
-  
+  private boolean finished = false; // see finish()
+
   private int retryPause = 500;
   private int maxRetriesOnForward = MAX_RETRIES_ON_FORWARD;
   
@@ -86,6 +87,9 @@ public class SolrCmdDistributor {
   
   public void finish() {    
     try {
+      assert ! finished : "lifecycle sanity check";
+      finished = true;
+      
       blockAndDoRetries();
     } finally {
       clients.shutdown();
@@ -227,7 +231,7 @@ public class SolrCmdDistributor {
     
   }
 
-  private void blockAndDoRetries() {
+  public void blockAndDoRetries() {
     clients.blockUntilFinished();
     
     // wait for any async commits to complete

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e603565d/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 94c14f6..0b936b2 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -221,6 +221,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
   
   public static final String COMMIT_END_POINT = "commit_end_point";
   public static final String LOG_REPLAY = "log_replay";
+
+  // used to assert we don't call finish more than once, see finish()
+  private boolean finished = false;
   
   private final SolrQueryRequest req;
   private final SolrQueryResponse rsp;
@@ -1414,7 +1417,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
       }
 
       if (someReplicas)  {
-        cmdDistrib.finish();
+        cmdDistrib.blockAndDoRetries();
       }
     }
 
@@ -1609,7 +1612,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
             zkController.getBaseUrl(), req.getCore().getName()));
         if (nodes != null) {
           cmdDistrib.distribCommit(cmd, nodes, params);
-          finish();
+          cmdDistrib.blockAndDoRetries();
         }
       }
     }
@@ -1636,6 +1639,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
   
   @Override
   public void finish() throws IOException {
+    assert ! finished : "lifecycle sanity check";
+    finished = true;
+    
     if (zkEnabled) doFinish();
     
     if (next != null && nodes == null) next.finish();