luoyuan3471 commented on code in PR #8752:
URL: https://github.com/apache/hadoop/pull/8752#discussion_r4657274416


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java:
##########
@@ -921,15 +921,15 @@ private ContainerAllocation allocate(Resource 
clusterResource,
       // iterator could not fit and returns RESERVED allocation.
       if (AllocationState.RESERVED == result.getAllocationState()) {

Review Comment:
   Thanks for the detailed repro. I confirmed that the rejected proposals kept 
app2 from getting its 1 GB container. The fallback now skips a new reservation 
on a node holding a different reservation and still allows the same container 
to re-reserve. If the conflicting node is the last candidate and there is no 
valid fallback, we return `PRIORITY_SKIPPED`. I added your scenario as a 
regression test.



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java:
##########
@@ -146,6 +149,113 @@ public void testAsyncContainerAllocationWithMultiNode() 
throws Exception {
     testAsyncContainerAllocation(2);
   }
 
+  @Test
+  @Timeout(value = 60)
+  public void testConflictingMultiNodeReservationProposals() throws Exception {
+    CapacitySchedulerConfiguration csConf =
+        new CapacitySchedulerConfiguration(conf);
+    csConf.setBoolean(
+        CapacitySchedulerConfiguration.MULTI_NODE_PLACEMENT_ENABLED, true);
+    csConf.set(CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICIES,
+        "resource-based");
+    csConf.set(CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICY_NAME,
+        "resource-based");
+    String policy = 
CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICY_NAME
+        + ".resource-based";
+    csConf.set(policy + ".class", POLICY_CLASS_NAME);
+    csConf.setInt(policy + ".sorting-interval.ms", 0);
+    csConf.setInt(
+        CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD, 
1);
+    csConf.setMaximumApplicationMasterResourcePerQueuePercent(
+        new QueuePath("root.default"), 1.0f);
+
+    List<CSAssignment> reservations = new ArrayList<>();
+    List<Boolean> commitResults = new ArrayList<>();
+    CountDownLatch committed = new CountDownLatch(2);
+    CapacityScheduler cs = new CapacityScheduler() {
+      @Override
+      public void submitResourceCommitRequest(Resource cluster,
+          CSAssignment assignment) {
+        if (assignment.getAssignmentInformation().getNumReservations() == 0) {
+          super.submitResourceCommitRequest(cluster, assignment);
+          return;
+        }
+        if (reservations.size() == 2) {
+          return;
+        }
+        // Generate both proposals while the target node is still unreserved.
+        reservations.add(assignment);
+        if (reservations.size() == 2) {
+          
getAsyncSchedulerThreads().forEach(AsyncScheduleThread::suspendSchedule);
+          for (CSAssignment reservation : reservations) {
+            super.submitResourceCommitRequest(cluster, reservation);
+          }
+        }
+      }
+
+      @Override
+      public boolean tryCommit(Resource cluster, ResourceCommitRequest request,
+          boolean updatePending) {
+        boolean accepted = super.tryCommit(cluster, request, updatePending);
+        if (!request.getContainersToReserve().isEmpty()) {
+          commitResults.add(accepted);
+          committed.countDown();
+        }
+        return accepted;
+      }
+    };
+    cs.setConf(csConf);
+    try (MockRM rm = new MockRM(csConf) {
+      @Override
+      protected ResourceScheduler createScheduler() {
+        return cs;
+      }
+    }) {
+      rm.start();
+      assertTrue(cs.getConfiguration().getScheduleAynschronously());
+      MockNM nm1 = rm.registerNode("h1:1234", 5 * GB);

Review Comment:
   Good catch. I raised `SCHEDULER_SKIP_NODE_MULTIPLIER` in this test and 
verified that both proposals reach the async committer even with a 2.5-second 
delay before `allocate`.



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerMultiNodes.java:
##########
@@ -522,6 +523,63 @@ public void testMultiNodeSorterAfterHeartbeatInterval() 
throws Exception {
     rm.stop();
   }
 
+  @Test
+  @Timeout(value = 30)
+  public void testReservationPreservedAfterLaterNodeSkipped()
+      throws Exception {
+    CapacitySchedulerConfiguration newConf =
+        new CapacitySchedulerConfiguration(conf);
+    
newConf.setInt(CapacitySchedulerConfiguration.MULTI_NODE_SORTING_POLICY_NAME
+        + ".resource-based.sorting-interval.ms", 0);
+    newConf.setMaximumApplicationMasterResourcePerQueuePercent(DEFAULT, 1.0f);
+    MockRM rm = new MockRM(newConf);
+
+    try {
+      rm.start();
+      MockNM nm1 = rm.registerNode("h1:1234", 5 * GB);

Review Comment:
   I confirmed the false positive with the pre-fix allocator. I raised the 
multiplier here too so h2 stays eligible and is visited after h1. With the same 
2.5-second delay, the test now fails against the old allocator and passes with 
the fix.



-- 
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]

Reply via email to