ruanwenjun commented on code in PR #18736:
URL: 
https://github.com/apache/dolphinscheduler/pull/18736#discussion_r4375815381


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/TaskExecutorEventListenerImpl.java:
##########
@@ -161,23 +207,90 @@ public void onTaskExecutorKilled(final 
TaskExecutorKilledLifecycleEvent taskExec
     public void onTaskExecutorPaused(final TaskExecutorPausedLifecycleEvent 
taskExecutorPausedLifecycleEvent) {
         
LogUtils.setWorkflowInstanceIdMDC(taskExecutorPausedLifecycleEvent.getWorkflowInstanceId());
         try {
+            final IWorkflowExecution workflowExecution =
+                    
workflowRepository.get(taskExecutorPausedLifecycleEvent.getWorkflowInstanceId());
+            if (workflowExecution == null) {
+                ackTaskExecutorTerminalEvent(taskExecutorPausedLifecycleEvent, 
TaskExecutionStatus.PAUSE,
+                        
taskExecutorPausedLifecycleEvent.getTaskInstanceHost());
+                return;
+            }
             final ITaskExecution taskExecution =
-                    getTaskExecution(taskExecutorPausedLifecycleEvent);
+                    getTaskExecution(taskExecutorPausedLifecycleEvent, 
workflowExecution);
             final TaskPausedLifecycleEvent taskPausedEvent = 
TaskPausedLifecycleEvent.of(taskExecution);
             taskExecution.getWorkflowEventBus().publish(taskPausedEvent);
         } finally {
             LogUtils.removeWorkflowInstanceIdMDC();
         }
     }
 
+    private void ackTaskExecutorTerminalEvent(final 
IReportableTaskExecutorLifecycleEvent event,

Review Comment:
   Is there a better way to implement this? Right now, it's hard to tell that 
this logic is intended for scenarios like failover.



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/client/ITaskExecutorClient.java:
##########
@@ -72,4 +73,12 @@ void ackTaskExecutorLifecycleEvent(
                                        final ITaskExecution taskExecution,
                                        final 
ITaskExecutorLifecycleEventReporter.TaskExecutorLifecycleEventAck 
taskExecutorLifecycleEventAck);
 
+    /**
+     * Send an acknowledgement using a persisted task instance after its 
workflow has been released.
+     * <p> Like the execution-based overload, a failed send is retried by the 
executor engine.
+     */
+    void ackTaskExecutorLifecycleEvent(
+                                       final TaskInstance taskInstance,

Review Comment:
   ```suggestion
                                          final ITaskExecution taskExecution,
   ```
   
   Donot change the interface style here.



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/TaskExecutorEventListenerImpl.java:
##########
@@ -129,8 +161,15 @@ public void onTaskExecutorSuccess(final 
TaskExecutorSuccessLifecycleEvent taskEx
     public void onTaskExecutorFailed(final TaskExecutorFailedLifecycleEvent 
taskExecutorFailedLifecycleEvent) {
         
LogUtils.setWorkflowInstanceIdMDC(taskExecutorFailedLifecycleEvent.getWorkflowInstanceId());
         try {
+            final IWorkflowExecution workflowExecution =
+                    
workflowRepository.get(taskExecutorFailedLifecycleEvent.getWorkflowInstanceId());
+            if (workflowExecution == null) {
+                ackTaskExecutorTerminalEvent(taskExecutorFailedLifecycleEvent, 
TaskExecutionStatus.FAILURE,
+                        
taskExecutorFailedLifecycleEvent.getTaskInstanceHost());
+                return;
+            }

Review Comment:
   Need to check if the task instance status is failed in DB.



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