Skip to content

Commit 2ee2b05

Browse files
committed
YARN-1724. Race condition in Fair Scheduler when continuous scheduling is turned on (Sandy Ryza)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1569447 13f79535-47bb-0310-9956-ffa450edef68
1 parent fe3ec37 commit 2ee2b05

File tree

2 files changed

+10
-1
lines changed
  • hadoop-yarn-project
    • hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair

2 files changed

+10
-1
lines changed

hadoop-yarn-project/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ Release 2.4.0 - UNRELEASED
292292
YARN-1721. When moving app between queues in Fair Scheduler, grab lock on
293293
FSSchedulerApp (Sandy Ryza)
294294

295+
YARN-1724. Race condition in Fair Scheduler when continuous scheduling is
296+
turned on (Sandy Ryza)
297+
295298
Release 2.3.1 - UNRELEASED
296299

297300
INCOMPATIBLE CHANGES

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,13 @@ private synchronized void nodeUpdate(RMNode nm) {
989989
private void continuousScheduling() {
990990
while (true) {
991991
List<NodeId> nodeIdList = new ArrayList<NodeId>(nodes.keySet());
992-
Collections.sort(nodeIdList, nodeAvailableResourceComparator);
992+
// Sort the nodes by space available on them, so that we offer
993+
// containers on emptier nodes first, facilitating an even spread. This
994+
// requires holding the scheduler lock, so that the space available on a
995+
// node doesn't change during the sort.
996+
synchronized (this) {
997+
Collections.sort(nodeIdList, nodeAvailableResourceComparator);
998+
}
993999

9941000
// iterate all nodes
9951001
for (NodeId nodeId : nodeIdList) {

0 commit comments

Comments
 (0)