You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2020/08/06 17:58:24 UTC
[helix] branch master updated: Identify and shutdown leaked timer
threads (#1201)
This is an automated email from the ASF dual-hosted git repository.
jiajunwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 151ac02 Identify and shutdown leaked timer threads (#1201)
151ac02 is described below
commit 151ac02ff450d5194f79e6c8142656cf41a40d98
Author: kaisun2000 <52...@users.noreply.github.com>
AuthorDate: Thu Aug 6 10:58:18 2020 -0700
Identify and shutdown leaked timer threads (#1201)
Unit test has leaked several hundreds to thousand leaked timer threads.
This pull request give each timer thread a name to help identified the
leaked threads. Also fix the major contributor of leaking in controller.
Co-authored-by: Kai Sun <ks...@ksun-mn1.linkedin.biz>
---
.../apache/helix/controller/GenericHelixController.java | 14 +++++++++++---
.../java/org/apache/helix/messaging/AsyncCallback.java | 2 +-
.../apache/helix/messaging/handling/HelixTaskExecutor.java | 2 +-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index ca8cc8d..b2ab6ae 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -334,7 +334,8 @@ public class GenericHelixController implements IdealStateChangeListener, LiveIns
if (_periodicalRebalanceTimer != null) {
_periodicalRebalanceTimer.cancel();
}
- _periodicalRebalanceTimer = new Timer(true);
+ _periodicalRebalanceTimer =
+ new Timer("GenericHelixController_" + _clusterName + "_periodical_Timer", true);
_timerPeriod = period;
_periodicalRebalanceTimer
.scheduleAtFixedRate(new RebalanceTask(manager, ClusterEventType.PeriodicalRebalance),
@@ -357,6 +358,12 @@ public class GenericHelixController implements IdealStateChangeListener, LiveIns
}
}
+ private void shutdownOnDemandTimer() {
+ logger.info("GenericHelixController stopping onDemand timer");
+ if (_onDemandRebalanceTimer != null) {
+ _onDemandRebalanceTimer.cancel();
+ }
+ }
/**
* This function is deprecated. Please use RebalanceUtil.scheduleInstantPipeline method instead.
* schedule a future rebalance pipeline run, delayed at given time.
@@ -600,7 +607,8 @@ public class GenericHelixController implements IdealStateChangeListener, LiveIns
_asyncFIFOWorkerPool = new HashMap<>();
initializeAsyncFIFOWorkers();
- _onDemandRebalanceTimer = new Timer(true);
+ _onDemandRebalanceTimer =
+ new Timer("GenericHelixController_" + _clusterName + "_onDemand_Timer", true);
// initialize pipelines at the end so we have everything else prepared
if (_enabledPipelineTypes.contains(Pipeline.Type.DEFAULT)) {
@@ -1272,7 +1280,7 @@ public class GenericHelixController implements IdealStateChangeListener, LiveIns
public void shutdown() throws InterruptedException {
stopPeriodRebalance();
-
+ shutdownOnDemandTimer();
logger.info("Shutting down {} pipeline", Pipeline.Type.DEFAULT.name());
shutdownPipeline(_eventThread, _eventQueue);
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java b/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
index 356b764..bc4dee2 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
@@ -109,7 +109,7 @@ public abstract class AsyncCallback {
if (_startTimeStamp == 0) {
_startTimeStamp = System.currentTimeMillis();
}
- _timer = new Timer(true);
+ _timer = new Timer("AsyncCallback-Timer", true);
_timer.schedule(new TimeoutTask(this), _timeout);
}
}
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
index 33182b6..9335b72 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
@@ -175,7 +175,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor {
_lock = new Object();
_statusUpdateUtil = new StatusUpdateUtil();
- _timer = new Timer(true); // created as a daemon timer thread to handle task timeout
+ _timer = new Timer("HelixTaskExecutor_timer", true); // created as a daemon timer thread to handle task timeout
_isShuttingDown = false;