slfan1989 commented on code in PR #8747:
URL: https://github.com/apache/hadoop/pull/8747#discussion_r4092081972


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueueManagementDynamicEditPolicy.java:
##########
@@ -183,47 +183,52 @@ List<QueueManagementChange> manageAutoCreatedLeafQueues()
 
     List<QueueManagementChange> queueManagementChanges =
         Collections.emptyList();
-    if (!parentQueue.shouldFailAutoCreationWhenGuaranteedCapacityExceeded()) {
-
-      AutoCreatedQueueManagementPolicy policyClazz =
-          parentQueue.getAutoCreatedQueueManagementPolicy();
-      long startTime = 0;
-      try {
-        startTime = clock.getTime();
-
-        queueManagementChanges = policyClazz.computeQueueManagementChanges();
-
-        //Scheduler update is asynchronous
-        if (queueManagementChanges.size() > 0) {
-          QueueManagementChangeEvent queueManagementChangeEvent =
-              new QueueManagementChangeEvent(parentQueue,
-                  queueManagementChanges);
-          scheduler.getRMContext().getDispatcher().getEventHandler().handle(
-              queueManagementChangeEvent);
-        }
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("{} uses {} millisecond" + " to run",
-              policyClazz.getClass().getName(), clock.getTime() - startTime);
+    parentQueue.getReadLock().lock();

Review Comment:
   This read lock introduces a read-to-write lock upgrade deadlock.
   
   `GuaranteedOrZeroCapacityOverTimePolicy.computeQueueManagementChanges()` 
calls
   `managedParentQueue.updateTemplateCapacitiesForAbsoluteResource()`, which 
unconditionally acquires the same parent's write lock before checking the 
capacity mode.
   
   Since `ReentrantReadWriteLock` does not support upgrading a held read lock 
to the write lock, the monitor thread will block on itself whenever it reaches 
this path, even without a concurrent queue refresh.
   
   Please revise the locking strategy to accommodate this write-lock 
acquisition and add a bounded regression test exercising the real policy 
through `QueueManagementDynamicEditPolicy`.
   



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