From d8b9a756311200675874345391485421e7cca327 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Wed, 23 May 2012 15:31:46 +0000 Subject: [PATCH] cancelRecovery wasn't being called, check for close between small sleeps, set closed even if we get an exception talking to ZK git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1341899 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/solr/cloud/RecoveryStrategy.java | 18 +++++++++++---- .../org/apache/solr/core/CoreContainer.java | 23 ++++++++----------- .../solr/update/DefaultSolrCoreState.java | 1 - 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java index 6cca4cf3f91..134b94eeb3b 100644 --- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java +++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java @@ -92,6 +92,7 @@ public class RecoveryStrategy extends Thread implements SafeStopThread { // 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 Thread implements SafeStopThread { 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 Thread implements SafeStopThread { } } 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 coreStates = null; + ArrayList coreStates = new ArrayList(); synchronized (cores) { - for (SolrCore core : cores.values()) { - try { - coreStates = new ArrayList(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); } } } diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java index bcc6d9a9915..8b49df586e2 100644 --- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java +++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java @@ -153,7 +153,6 @@ public final class DefaultSolrCoreState extends SolrCoreState { synchronized (recoveryLock) { if (recoveryStrat != null) { recoveryStrat.close(); - try { recoveryStrat.join(); } catch (InterruptedException e) {