diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 7f4a874200..98b416da2e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -164,6 +164,9 @@ Release 2.0.3-alpha - Unreleased YARN-300. After YARN-271, fair scheduler can infinite loop and not schedule any application. (Sandy Ryza via tomwhite) + YARN-301. Fair scheduler throws ConcurrentModificationException when + iterating over app's priorities. (Sandy Ryza via tomwhite) + Release 2.0.2-alpha - 2012-09-07 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/AppSchedulable.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/AppSchedulable.java index d26e7cad6f..376603e36f 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/AppSchedulable.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/AppSchedulable.java @@ -305,34 +305,36 @@ public Resource assignContainer(FSSchedulerNode node, boolean reserved) { // For each priority, see if we can schedule a node local, rack local // or off-switch request. Rack of off-switch requests may be delayed // (not scheduled) in order to promote better locality. - for (Priority priority : prioritiesToTry) { - app.addSchedulingOpportunity(priority); - NodeType allowedLocality = app.getAllowedLocalityLevel(priority, - scheduler.getNumClusterNodes(), scheduler.getNodeLocalityThreshold(), - scheduler.getRackLocalityThreshold()); + synchronized (app) { + for (Priority priority : prioritiesToTry) { + app.addSchedulingOpportunity(priority); + NodeType allowedLocality = app.getAllowedLocalityLevel(priority, + scheduler.getNumClusterNodes(), scheduler.getNodeLocalityThreshold(), + scheduler.getRackLocalityThreshold()); - ResourceRequest localRequest = app.getResourceRequest(priority, - node.getHostName()); - if (localRequest != null && localRequest.getNumContainers() != 0) { - return assignContainer(node, app, priority, - localRequest, NodeType.NODE_LOCAL, reserved); - } + ResourceRequest localRequest = app.getResourceRequest(priority, + node.getHostName()); + if (localRequest != null && localRequest.getNumContainers() != 0) { + return assignContainer(node, app, priority, + localRequest, NodeType.NODE_LOCAL, reserved); + } - ResourceRequest rackLocalRequest = app.getResourceRequest(priority, - node.getRackName()); - if (rackLocalRequest != null && rackLocalRequest.getNumContainers() != 0 - && (allowedLocality.equals(NodeType.RACK_LOCAL) || - allowedLocality.equals(NodeType.OFF_SWITCH))) { - return assignContainer(node, app, priority, rackLocalRequest, - NodeType.RACK_LOCAL, reserved); - } + ResourceRequest rackLocalRequest = app.getResourceRequest(priority, + node.getRackName()); + if (rackLocalRequest != null && rackLocalRequest.getNumContainers() != 0 + && (allowedLocality.equals(NodeType.RACK_LOCAL) || + allowedLocality.equals(NodeType.OFF_SWITCH))) { + return assignContainer(node, app, priority, rackLocalRequest, + NodeType.RACK_LOCAL, reserved); + } - ResourceRequest offSwitchRequest = app.getResourceRequest(priority, - RMNode.ANY); - if (offSwitchRequest != null && offSwitchRequest.getNumContainers() != 0 - && allowedLocality.equals(NodeType.OFF_SWITCH)) { - return assignContainer(node, app, priority, offSwitchRequest, - NodeType.OFF_SWITCH, reserved); + ResourceRequest offSwitchRequest = app.getResourceRequest(priority, + RMNode.ANY); + if (offSwitchRequest != null && offSwitchRequest.getNumContainers() != 0 + && allowedLocality.equals(NodeType.OFF_SWITCH)) { + return assignContainer(node, app, priority, offSwitchRequest, + NodeType.OFF_SWITCH, reserved); + } } } return Resources.none();