Skip to content

Commit 615f4fe

Browse files
authored
YARN-11838: YARN ConcurrentModificationException When Refreshing Node Attributes (#7828) Contributed by Syed Shameerur Rahman.
* YARN-11838: YARN ConcurrentModificationException When Refreshing Node Attributes. Signed-off-by: Shilun Fan <[email protected]>
1 parent 23121f9 commit 615f4fe

File tree

1 file changed

+8
-1
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels

1 file changed

+8
-1
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/NodeAttributesManagerImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,14 @@ public void refreshNodeAttributesToScheduler(NodeId nodeId) {
741741
if (host == null || host.attributes == null) {
742742
return;
743743
}
744-
newNodeToAttributesMap.put(hostName, host.attributes.keySet());
744+
// Use read lock and create defensive copy since
745+
// other threads might access host.attributes
746+
readLock.lock();
747+
try {
748+
newNodeToAttributesMap.put(hostName, new HashSet<>(host.attributes.keySet()));
749+
} finally {
750+
readLock.unlock();
751+
}
745752

746753
// Notify RM
747754
if (rmContext != null && rmContext.getDispatcher() != null) {

0 commit comments

Comments
 (0)