jiajie999 opened a new pull request, #8354: URL: https://github.com/apache/hadoop/pull/8354
### Description of PR Fix ConcurrentModificationException in `NodeAttributesManagerImpl.internalUpdateAttributesOnNodes()`. `internalUpdateAttributesOnNodes()` passes a live `HashMap.keySet()` view into `newNodeToAttributesMap`. When `LOG.info()` calls `toString()` on this map, it iterates the live keySet while concurrent IPC handler threads may modify `host.attributes`, causing `ConcurrentModificationException` and crashing the ResourceManager. This is the exact same bug pattern that was fixed in `refreshNodeAttributesToScheduler()` by YARN-11838, but was missed for `internalUpdateAttributesOnNodes()`. **Fix:** Replace `node.attributes.keySet()` with `new 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: - [x] Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')? - [x] Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation? - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [x] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, `NOTICE-binary` files? ### AI Tooling - [x] The PR includes the phrase "Contains content generated by Kiro" - [x] My use of AI contributions follows the ASF legal policy https://www.apache.org/legal/generative-tooling.html -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
