lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1341899 - in /lucene/dev/trunk/solr/core/src/java/org/apache/solr: cloud/RecoveryStrategy.java core/CoreContainer.java update/DefaultSolrCoreState.java
Date Wed, 23 May 2012 15:31:46 GMT
Author: yonik
Date: Wed May 23 15:31:46 2012
New Revision: 1341899

URL: http://svn.apache.org/viewvc?rev=1341899&view=rev
Log:
cancelRecovery wasn't being called, check for close between small sleeps, set closed even
if we get an exception talking to ZK

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java?rev=1341899&r1=1341898&r2=1341899&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java Wed May
23 15:31:46 2012
@@ -92,6 +92,7 @@ public class RecoveryStrategy extends Th
   // make sure any threads stop retrying
   public void close() {
     close = true;
+    log.warn("Stopping recovery for core " + coreName + " zkNodeName=" + coreZkNodeName);
   }
 
   
@@ -99,9 +100,12 @@ public class RecoveryStrategy extends Th
       final ZkController zkController, final String baseUrl,
       final String shardZkNodeName, final CoreDescriptor cd) {
     SolrException.log(log, "Recovery failed - I give up.");
-    zkController.publishAsRecoveryFailed(baseUrl, cd,
-        shardZkNodeName, core.getName());
-    close = true;
+    try {
+      zkController.publishAsRecoveryFailed(baseUrl, cd,
+          shardZkNodeName, core.getName());
+    } finally {
+      close();
+    }
   }
   
   private void replicate(String nodeName, SolrCore core, ZkNodeProps leaderprops, String
baseUrl)
@@ -393,11 +397,15 @@ public class RecoveryStrategy extends Th
           }
 
         } catch (Exception e) {
-          SolrException.log(log, "", e);
+          log.error("", e);
         }
 
         try {
-          Thread.sleep(Math.min(START_TIMEOUT * retries, 60000));
+          // if (!isClosed()) Thread.sleep(Math.min(START_TIMEOUT * retries, 60000));
+          for (int i = 0; i<Math.min(retries, 600); i++) {
+            if (isClosed()) break; // check if someone closed us
+            Thread.sleep(START_TIMEOUT);
+          }
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
           log.warn("Recovery was interrupted", e);

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1341899&r1=1341898&r2=1341899&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java Wed May 23
15:31:46 2012
@@ -582,23 +582,20 @@ public class CoreContainer 
   }
 
   private void cancelCoreRecoveries() {
-    ArrayList<SolrCoreState> coreStates = null;
+    ArrayList<SolrCoreState> coreStates = new ArrayList<SolrCoreState>();
     synchronized (cores) {
-        for (SolrCore core : cores.values()) {
-          try {
-            coreStates = new ArrayList<SolrCoreState>(cores.size());
-            // make sure we wait for any recoveries to stop
-            coreStates.add(core.getUpdateHandler().getSolrCoreState());
-          } catch (Throwable t) {
-            SolrException.log(log, "Error canceling recovery for core", t);
-          }
-        }
+      for (SolrCore core : cores.values()) {
+        coreStates.add(core.getUpdateHandler().getSolrCoreState());
+      }
     }
-    
+
     // we must cancel without holding the cores sync
-    if (coreStates != null) {
-      for (SolrCoreState coreState : coreStates) {
+    // make sure we wait for any recoveries to stop
+    for (SolrCoreState coreState : coreStates) {
+      try {
         coreState.cancelRecovery();
+      } catch (Throwable t) {
+        SolrException.log(log, "Error canceling recovery for core", t);
       }
     }
   }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java?rev=1341899&r1=1341898&r2=1341899&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java Wed
May 23 15:31:46 2012
@@ -153,7 +153,6 @@ public final class DefaultSolrCoreState 
     synchronized (recoveryLock) {
       if (recoveryStrat != null) {
         recoveryStrat.close();
-        
         try {
           recoveryStrat.join();
         } catch (InterruptedException e) {



Mime
View raw message