You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/04/01 17:39:52 UTC
[lucene-solr] branch branch_8x updated: SOLR-13352: Remove risk of
deadlock/threadleak when shutting down an Overseer(TriggerThread)
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new c18da4c SOLR-13352: Remove risk of deadlock/threadleak when shutting down an Overseer(TriggerThread)
c18da4c is described below
commit c18da4c6bc570a353960405aed644e7502270f1a
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Mon Apr 1 10:34:51 2019 -0700
SOLR-13352: Remove risk of deadlock/threadleak when shutting down an Overseer(TriggerThread)
(cherry picked from commit 1071d093360b2c5869a918de743c7089952094f4)
---
solr/CHANGES.txt | 2 ++
.../cloud/autoscaling/OverseerTriggerThread.java | 33 +++++++++-------------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 285704c..162a7d8 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -118,6 +118,8 @@ Bug Fixes
* SOLR-13349: High CPU usage in Solr due to Java 8 bug (Erick Erickson)
+* SOLR-13352: Remove risk of deadlock/threadleak when shutting down an Overseer(TriggerThread). (hossman)
+
Improvements
----------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
index de875fb..5758627 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
@@ -184,48 +184,43 @@ public class OverseerTriggerThread implements Runnable, SolrCloseable {
while (true) {
Map<String, AutoScaling.Trigger> copy = null;
try {
- // this can throw InterruptedException and we don't want to unlock if it did, so we keep this outside
- // of the try/finally block
+
updateLock.lockInterruptibly();
-
- // must check for close here before we await on the condition otherwise we can only be woken up on interruption
- if (isClosed) {
- log.info("OverseerTriggerThread has been closed, exiting.");
- break;
- }
-
- log.debug("Current znodeVersion {}, lastZnodeVersion {}", znodeVersion, lastZnodeVersion);
-
try {
+ // must check for close here before we await on the condition otherwise we can
+ // only be woken up on interruption
+ if (isClosed) {
+ log.info("OverseerTriggerThread has been closed, exiting.");
+ break;
+ }
+
+ log.debug("Current znodeVersion {}, lastZnodeVersion {}", znodeVersion, lastZnodeVersion);
+
if (znodeVersion == lastZnodeVersion) {
updated.await();
-
+
// are we closed?
if (isClosed) {
log.info("OverseerTriggerThread woken up but we are closed, exiting.");
break;
}
-
+
// spurious wakeup?
if (znodeVersion == lastZnodeVersion) continue;
}
copy = new HashMap<>(activeTriggers);
lastZnodeVersion = znodeVersion;
log.debug("Processed trigger updates upto znodeVersion {}", znodeVersion);
- } catch (InterruptedException e) {
- // Restore the interrupted status
- Thread.currentThread().interrupt();
- log.warn("Interrupted", e);
- break;
} finally {
updateLock.unlock();
}
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
+ log.warn("Interrupted", e);
break;
}
-
+
// update the current config
scheduledTriggers.setAutoScalingConfig(autoScalingConfig);