|
36 | 36 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskDispatchLifecycleEvent; |
37 | 37 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskDispatchedLifecycleEvent; |
38 | 38 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskFailedLifecycleEvent; |
| 39 | +import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskFatalLifecycleEvent; |
39 | 40 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskKilledLifecycleEvent; |
40 | 41 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskPausedLifecycleEvent; |
41 | 42 | import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskRetryLifecycleEvent; |
@@ -99,6 +100,38 @@ protected void releaseTaskInstanceResourcesIfNeeded(final ITaskExecutionRunnable |
99 | 100 | } |
100 | 101 | } |
101 | 102 |
|
| 103 | + @Override |
| 104 | + public void onFatalEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable, |
| 105 | + final ITaskExecutionRunnable taskExecutionRunnable, |
| 106 | + final TaskFatalLifecycleEvent taskFatalEvent) { |
| 107 | + releaseTaskInstanceResourcesIfNeeded(taskExecutionRunnable); |
| 108 | + persistentTaskInstanceFatalEventToDB(taskExecutionRunnable, taskFatalEvent); |
| 109 | + |
| 110 | + if (taskExecutionRunnable.isTaskInstanceCanRetry()) { |
| 111 | + taskExecutionRunnable.getWorkflowEventBus().publish(TaskRetryLifecycleEvent.of(taskExecutionRunnable)); |
| 112 | + return; |
| 113 | + } |
| 114 | + |
| 115 | + // If all successors are condition tasks, then the task will not be marked as failure. |
| 116 | + // And the DAG will continue to execute. |
| 117 | + final IWorkflowExecutionGraph workflowExecutionGraph = taskExecutionRunnable.getWorkflowExecutionGraph(); |
| 118 | + if (workflowExecutionGraph.isAllSuccessorsAreConditionTask(taskExecutionRunnable)) { |
| 119 | + mergeTaskVarPoolToWorkflow(workflowExecutionRunnable, taskExecutionRunnable); |
| 120 | + publishWorkflowInstanceTopologyLogicalTransitionEvent(taskExecutionRunnable); |
| 121 | + return; |
| 122 | + } |
| 123 | + taskExecutionRunnable.getWorkflowExecutionGraph().markTaskExecutionRunnableChainFailure(taskExecutionRunnable); |
| 124 | + publishWorkflowInstanceTopologyLogicalTransitionEvent(taskExecutionRunnable); |
| 125 | + } |
| 126 | + |
| 127 | + private void persistentTaskInstanceFatalEventToDB(final ITaskExecutionRunnable taskExecutionRunnable, |
| 128 | + final TaskFatalLifecycleEvent taskFatalEvent) { |
| 129 | + final TaskInstance taskInstance = taskExecutionRunnable.getTaskInstance(); |
| 130 | + taskInstance.setState(TaskExecutionStatus.FAILURE); |
| 131 | + taskInstance.setEndTime(taskFatalEvent.getEndTime()); |
| 132 | + taskInstanceDao.updateById(taskInstance); |
| 133 | + } |
| 134 | + |
102 | 135 | @Override |
103 | 136 | public void onDispatchedEvent(final IWorkflowExecutionRunnable workflowExecutionRunnable, |
104 | 137 | final ITaskExecutionRunnable taskExecutionRunnable, |
|
0 commit comments