eye-gu commented on code in PR #18344:
URL: 
https://github.com/apache/dolphinscheduler/pull/18344#discussion_r3409575448


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:
##########
@@ -143,6 +143,15 @@ public void onPauseEvent(final IWorkflowExecution 
workflowExecution,
             
taskExecution.getWorkflowEventBus().publish(TaskPausedLifecycleEvent.of(taskExecution));
             return;
         }
+        // Task not in dispatch queue, check if it's waiting for TaskGroup slot
+        if 
(taskGroupCoordinator.isTaskWaitingForTaskGroupSlot(taskExecution.getTaskInstance()))
 {
+            // Release the TaskGroupQueue first to prevent TaskGroupCoordinator
+            // from concurrently acquiring the slot and racing with this pause
+            
taskGroupCoordinator.releaseTaskGroupSlot(taskExecution.getTaskInstance());
+            log.info("Task: {} is waiting for TaskGroup slot, pause it 
directly", taskExecution.getName());
+            
taskExecution.getWorkflowEventBus().publish(TaskPausedLifecycleEvent.of(taskExecution));
+            return;
+        }

Review Comment:
   You're right, there is a concurrency issue with the TaskGroupCoordinator's 
periodic task. However, the leaked slot will be fixed by amendTaskGroupUseSize 
eventually, and after the task enters PAUSE state, the dispatch event triggered 
by TGC's RPC will be safely ignored (just a warn log). So in practice there's 
no real impact. Is this acceptable? I haven't come up with a clean way to fully 
fix the concurrency yet.



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

Reply via email to