commit | feef3319fbfa622b5585d6dd76e2759ae68ebd0e | [log] [tgz] |
---|---|---|
author | Ferenc Erdelyi <55103964+ferdelyi@users.noreply.github.com> | Thu Jan 25 16:24:20 2024 +0100 |
committer | GitHub <noreply@github.com> | Thu Jan 25 16:24:20 2024 +0100 |
tree | 591f0b6b6d613d4b5ca5d4da869c3398838a3082 | |
parent | 8cde3b7dc0715cfbfb9422b88a9d35df983e4495 [diff] |
YARN-11639. CME and NPE in PriorityUtilizationQueueOrderingPolicy (#6… (#6492)
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/capacity/policy/PriorityUtilizationQueueOrderingPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/PriorityUtilizationQueueOrderingPolicy.java index 1c27591..b604e91 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/PriorityUtilizationQueueOrderingPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/PriorityUtilizationQueueOrderingPolicy.java
@@ -28,6 +28,7 @@ .CapacitySchedulerConfiguration; import org.apache.hadoop.yarn.util.resource.Resources; +import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -254,9 +255,9 @@ // partitionToLookAt is a thread local variable, therefore it is safe to mutate it. PriorityUtilizationQueueOrderingPolicy.partitionToLookAt.set(partition); - // Sort the snapshot of the queues in order to avoid breaking the prerequisites of TimSort. - // See YARN-10178 for details. - return queues.stream().map(PriorityQueueResourcesForSorting::new).sorted( + // Copy (for thread safety) and sort the snapshot of the queues in order to avoid breaking + // the prerequisites of TimSort. See YARN-10178 for details. + return new ArrayList<>(queues).stream().map(PriorityQueueResourcesForSorting::new).sorted( new PriorityQueueComparator()).map(PriorityQueueResourcesForSorting::getQueue).collect( Collectors.toList()).iterator(); }