mirror of https://github.com/apache/lucene.git
do not hold the cores lock while calling cancel on recovery
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1294004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
71674efc04
commit
74037691e6
|
@ -66,6 +66,7 @@ import org.apache.solr.handler.admin.CoreAdminHandler;
|
||||||
import org.apache.solr.handler.component.HttpShardHandlerFactory;
|
import org.apache.solr.handler.component.HttpShardHandlerFactory;
|
||||||
import org.apache.solr.handler.component.ShardHandlerFactory;
|
import org.apache.solr.handler.component.ShardHandlerFactory;
|
||||||
import org.apache.solr.schema.IndexSchema;
|
import org.apache.solr.schema.IndexSchema;
|
||||||
|
import org.apache.solr.update.SolrCoreState;
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -485,14 +486,16 @@ public class CoreContainer
|
||||||
* Stops all cores.
|
* Stops all cores.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
log.info("Shutting down CoreContainer instance="+System.identityHashCode(this));
|
log.info("Shutting down CoreContainer instance="+System.identityHashCode(this));
|
||||||
|
if (isZooKeeperAware()) {
|
||||||
|
cancelCoreRecoveries();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized(cores) {
|
synchronized(cores) {
|
||||||
try {
|
try {
|
||||||
for (SolrCore core : cores.values()) {
|
for (SolrCore core : cores.values()) {
|
||||||
try {
|
try {
|
||||||
core.close();
|
core.close();
|
||||||
// make sure we wait for any recoveries to stop
|
|
||||||
core.getUpdateHandler().getSolrCoreState().cancelRecovery();
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
SolrException.log(log, "Error shutting down core", t);
|
SolrException.log(log, "Error shutting down core", t);
|
||||||
}
|
}
|
||||||
|
@ -512,6 +515,28 @@ public class CoreContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelCoreRecoveries() {
|
||||||
|
ArrayList<SolrCoreState> coreStates = null;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we must cancel without holding the cores sync
|
||||||
|
if (coreStates != null) {
|
||||||
|
for (SolrCoreState coreState : coreStates) {
|
||||||
|
coreState.cancelRecovery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
|
|
Loading…
Reference in New Issue