Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-7956: There are interrupts on shutdown in places that can cause ChannelAlreadyClosed exceptions which prevents proper closing of transaction logs, interfere with the IndexWriter, the hdfs client and other things.

Mark Robert Millera956d3ffe258
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 528a896fb8d..9f4ac215121 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -45,7 +45,7 @@ Upgrading from Solr 5.x
* SolrClient.shutdown() has been removed, use SolrClient.close() instead.
* The deprecated zkCredientialsProvider element in solrcloud section of solr.xml
- is now removed. Use the correct spelling (zkCredentialsProvider) instead.
+ is now removed. Use tI'll start looking at it today. - Mark On Wed, Aug 19, 2015 at 10:15 PM Gregory Chanan <he correct spelling (zkCredentialsProvider) instead.
* SOLR-7957: internal/expert - ResultContext was significantly changed and expanded
to allow for multiple full query results (DocLists) per Solr request.
@@ -77,7 +77,7 @@ Other Changes
* SOLR-6954: Deprecated SolrClient.shutdown() method removed (Alan Woodward)
* SOLR-7355: Switch from Google's ConcurrentLinkedHashMap to Caffeine. Only
- affects HDFS support. (Ben Manes via Shawn Heisey)
+ affects HDFS support. (Ben Manes viI'll start looking at it today. - Mark On Wed, Aug 19, 2015 at 10:15 PM Gregory Chanan <a Shawn Heisey)
* SOLR-7624: Remove deprecated zkCredientialsProvider element in solrcloud section of solr.xml.
(Xu Zhang, Per Steffensen, Ramkumar Aiyengar, Mark Miller)
@@ -162,7 +162,8 @@ Bug Fixes
* SOLR-7949: Resolve XSS issue in Admin UI stats page (David Chiu via janhoy)
* SOLR-7956: There are interrupts on shutdown in places that can cause ChannelAlreadyClosed
- exceptions which prevents proper closing of transaction logs. (Mark Miller)
+ exceptions which prevents proper closing of transaction logs, interfere with the IndexWriter,
+ the hdfs client and other things. (Mark Miller, Scott Blum)
* SOLR-7972: Fix VelocityResponseWriter template encoding issue.
Templates must be UTF-8 encoded. (Erik Hatcher)
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 22600c1c2e1..1bcea965664 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -486,7 +486,7 @@ public class CoreContainer {
}
}
} finally {
- ExecutorUtil.shutdownNowAndAwaitTermination(coreLoadExecutor);
+ ExecutorUtil.shutdownAndAwaitTermination(coreLoadExecutor);
}
}
};
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index 86d82b5a965..f05ce8649f2 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -41,6 +41,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
@@ -116,6 +117,8 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
private static final Logger LOG = LoggerFactory.getLogger(ReplicationHandler.class.getName());
SolrCore core;
+
+ private volatile boolean closed = false;
private static final class CommitVersionInfo {
public final long version;
@@ -1214,16 +1217,11 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
@Override
public void preClose(SolrCore core) {
try {
- if (executorService != null) executorService.shutdown();
+ if (executorService != null) executorService.shutdown(); // we don't wait for shutdown - this can deadlock core reload
} finally {
- try {
if (pollingIndexFetcher != null) {
pollingIndexFetcher.destroy();
}
- } finally {
- if (executorService != null) ExecutorUtil
- .shutdownNowAndAwaitTermination(executorService);
- }
}
if (currentIndexFetcher != null && currentIndexFetcher != pollingIndexFetcher) {
currentIndexFetcher.destroy();
@@ -1237,9 +1235,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
core.addCloseHook(new CloseHook() {
@Override
public void preClose(SolrCore core) {
- ExecutorUtil.shutdownNowAndAwaitTermination(restoreExecutor);
+ ExecutorUtil.shutdownAndAwaitTermination(restoreExecutor);
if (restoreFuture != null) {
- restoreFuture.cancel(true);
+ restoreFuture.cancel(false);
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index f214265e7b2..8f9c901c0be 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -317,9 +317,7 @@ public class HttpShardHandler extends ShardHandler {
@Override
public void cancelAll() {
for (Future<ShardResponse> future : pending) {
- // TODO: any issues with interrupting? shouldn't be if
- // there are finally blocks to release connections.
- future.cancel(true);
+ future.cancel(false);
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/CommitTracker.java b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
index 96633db4ff2..15481c86b42 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitTracker.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
@@ -89,7 +89,7 @@ public final class CommitTracker implements Runnable {
public synchronized void close() {
if (pending != null) {
- pending.cancel(true);
+ pending.cancel(false);
pending = null;
}
scheduler.shutdownNow();
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 0d0876f302f..071ab17041c 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -906,7 +906,7 @@ public class UpdateLog implements PluginInfoInitialized {
}
try {
- ExecutorUtil.shutdownNowAndAwaitTermination(recoveryExecutor);
+ ExecutorUtil.shutdownAndAwaitTermination(recoveryExecutor);
} catch (Exception e) {
SolrException.log(log, e);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
index f0c6e05f0a0..6435c3bbea3 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
@@ -78,8 +78,10 @@ public class ExecutorUtil {
public void clean(AtomicReference<?> ctx);
}
- // this will interrupt the threads! Lucene and Solr do not like this because it can close channels, so only use
- // this if you know what you are doing - you probably want shutdownAndAwaitTermination
+ // ** This will interrupt the threads! ** Lucene and Solr do not like this because it can close channels, so only use
+ // this if you know what you are doing - you probably want shutdownAndAwaitTermination.
+ // Marked as Deprecated to discourage use.
+ @Deprecated
public static void shutdownNowAndAwaitTermination(ExecutorService pool) {
pool.shutdown(); // Disable new tasks from being submitted
pool.shutdownNow(); // Cancel currently executing tasks - NOTE: this interrupts!