YARN-9642. Fix Memory Leak in AbstractYarnScheduler caused by timer. Contributed by Bibin A Chundatt.
(cherry picked from commit d3ce53e507
)
This commit is contained in:
parent
d2bb764ffa
commit
eb618e4f22
|
@ -141,6 +141,7 @@ public abstract class AbstractYarnScheduler
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Thread updateThread;
|
Thread updateThread;
|
||||||
private final Object updateThreadMonitor = new Object();
|
private final Object updateThreadMonitor = new Object();
|
||||||
|
private Timer releaseCache;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All schedulers which are inheriting AbstractYarnScheduler should use
|
* All schedulers which are inheriting AbstractYarnScheduler should use
|
||||||
|
@ -201,7 +202,7 @@ public abstract class AbstractYarnScheduler
|
||||||
nodeTracker.setConfiguredMaxAllocationWaitTime(
|
nodeTracker.setConfiguredMaxAllocationWaitTime(
|
||||||
configuredMaximumAllocationWaitTime);
|
configuredMaximumAllocationWaitTime);
|
||||||
maxClusterLevelAppPriority = getMaxPriorityFromConf(conf);
|
maxClusterLevelAppPriority = getMaxPriorityFromConf(conf);
|
||||||
createReleaseCache();
|
this.releaseCache = new Timer("Pending Container Clear Timer");
|
||||||
autoUpdateContainers =
|
autoUpdateContainers =
|
||||||
conf.getBoolean(YarnConfiguration.RM_AUTO_UPDATE_CONTAINERS,
|
conf.getBoolean(YarnConfiguration.RM_AUTO_UPDATE_CONTAINERS,
|
||||||
YarnConfiguration.DEFAULT_RM_AUTO_UPDATE_CONTAINERS);
|
YarnConfiguration.DEFAULT_RM_AUTO_UPDATE_CONTAINERS);
|
||||||
|
@ -223,6 +224,7 @@ public abstract class AbstractYarnScheduler
|
||||||
updateThread.start();
|
updateThread.start();
|
||||||
}
|
}
|
||||||
schedulingMonitorManager.startAll();
|
schedulingMonitorManager.startAll();
|
||||||
|
createReleaseCache();
|
||||||
super.serviceStart();
|
super.serviceStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +234,12 @@ public abstract class AbstractYarnScheduler
|
||||||
updateThread.interrupt();
|
updateThread.interrupt();
|
||||||
updateThread.join(THREAD_JOIN_TIMEOUT_MS);
|
updateThread.join(THREAD_JOIN_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Stop Timer
|
||||||
|
if (releaseCache != null) {
|
||||||
|
releaseCache.cancel();
|
||||||
|
releaseCache = null;
|
||||||
|
}
|
||||||
schedulingMonitorManager.stop();
|
schedulingMonitorManager.stop();
|
||||||
super.serviceStop();
|
super.serviceStop();
|
||||||
}
|
}
|
||||||
|
@ -632,7 +640,7 @@ public abstract class AbstractYarnScheduler
|
||||||
|
|
||||||
protected void createReleaseCache() {
|
protected void createReleaseCache() {
|
||||||
// Cleanup the cache after nm expire interval.
|
// Cleanup the cache after nm expire interval.
|
||||||
new Timer().schedule(new TimerTask() {
|
releaseCache.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
clearPendingContainerCache();
|
clearPendingContainerCache();
|
||||||
|
|
Loading…
Reference in New Issue