diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 1a19f52803..99b900672e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -239,6 +239,9 @@ Release 2.5.0 - UNRELEASED YARN-2075. Fixed the test failure of TestRMAdminCLI. (Kenji Kikushima via zjshen) + YARN-2155. FairScheduler: Incorrect threshold check for preemption. + (Wei Yan via kasha) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java index 5725f8c383..ea53165c63 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java @@ -1072,8 +1072,8 @@ private void updateRootQueueMetrics() { private boolean shouldAttemptPreemption() { if (preemptionEnabled) { return (preemptionUtilizationThreshold < Math.max( - (float) rootMetrics.getAvailableMB() / clusterResource.getMemory(), - (float) rootMetrics.getAvailableVirtualCores() / + (float) rootMetrics.getAllocatedMB() / clusterResource.getMemory(), + (float) rootMetrics.getAllocatedVirtualCores() / clusterResource.getVirtualCores())); } return false; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java index 2098e1679b..310104bd08 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerPreemption.java @@ -146,7 +146,7 @@ public void testPreemptionWithFreeResources() throws Exception { // Create node with 4GB memory and 4 vcores registerNodeAndSubmitApp(4 * 1024, 4, 2, 1024); - // Verify submitting another request doesn't trigger preemption + // Verify submitting another request triggers preemption createSchedulingRequest(1024, "queueB", "user1", 1, 1); scheduler.update(); clock.tick(6); @@ -171,5 +171,21 @@ public void testPreemptionWithFreeResources() throws Exception { scheduler.preemptTasksIfNecessary(); assertEquals("preemptResources() should not have been called", -1, ((StubbedFairScheduler) scheduler).lastPreemptMemory); + + resourceManager.stop(); + + startResourceManager(0.7f); + // Create node with 4GB memory and 4 vcores + registerNodeAndSubmitApp(4 * 1024, 4, 3, 1024); + + // Verify submitting another request triggers preemption + createSchedulingRequest(1024, "queueB", "user1", 1, 1); + scheduler.update(); + clock.tick(6); + + ((StubbedFairScheduler) scheduler).resetLastPreemptResources(); + scheduler.preemptTasksIfNecessary(); + assertEquals("preemptResources() should have been called", 1024, + ((StubbedFairScheduler) scheduler).lastPreemptMemory); } }