YARN-11942. Fix ConcurrentModificationException in NodeAttributesManagerImpl.internalUpdateAttributesOnNodes()#8354
Open
jiajie999 wants to merge 1 commit intoapache:trunkfrom
Conversation
|
💔 -1 overall
This message was automatically generated. |
…gerImpl.internalUpdateAttributesOnNodes() Use defensive copy (new HashSet<>) for node.attributes.keySet() in internalUpdateAttributesOnNodes() to prevent ConcurrentModificationException when the attributes map is modified by concurrent IPC handler threads. This is the same pattern fixed in refreshNodeAttributesToScheduler() by YARN-11838, but was missed for internalUpdateAttributesOnNodes(). Contains content generated by Kiro.
aaf505d to
5b954bf
Compare
|
💔 -1 overall
This message was automatically generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Fix ConcurrentModificationException in
NodeAttributesManagerImpl.internalUpdateAttributesOnNodes().internalUpdateAttributesOnNodes()passes a liveHashMap.keySet()view intonewNodeToAttributesMap. WhenLOG.info()callstoString()on this map, it iterates the live keySet while concurrent IPC handler threads may modifyhost.attributes, causingConcurrentModificationExceptionand crashing the ResourceManager.This is the exact same bug pattern that was fixed in
refreshNodeAttributesToScheduler()by YARN-11838, but was missed forinternalUpdateAttributesOnNodes().Fix: Replace
node.attributes.keySet()withnew HashSet<>(node.attributes.keySet())to create a defensive copy.Stack trace from production (Hadoop 3.4.1, before YARN-11838 backport, same code path):
ERROR org.apache.hadoop.yarn.event.EventDispatcher: Error in handling event type NODE_ADDED to the Event Dispatcher
java.util.ConcurrentModificationException
at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1597)
at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1620)
at java.base/java.util.AbstractCollection.toString(AbstractCollection.java:456)
at org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NodeAttributesManagerImpl.refreshNodeAttributesToScheduler(...)
at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler.addNode(...)
How was this patch tested?
Code inspection. The fix is a one-line defensive copy, identical to the pattern applied in YARN-11838 for
refreshNodeAttributesToScheduler(). The bug was discovered in a production EMR 7.9.0 cluster (Hadoop 3.4.1) where multiple nodes registered simultaneously during managed scaling, triggering the race condition.For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
https://www.apache.org/legal/generative-tooling.html