Skip to content

Commit e9a8993

Browse files
author
苏义超
committed
throw TaskExecutionContextCreateException if initializeTaskExecutionContext fail
1 parent a710d36 commit e9a8993

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/WorkflowEventBusFireWorker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ private void doFireSingleWorkflowEventBus(final IWorkflowExecutionRunnable workf
131131
ThreadUtils.sleep(5_000);
132132
return;
133133
}
134-
if (ExceptionUtils.isIllegalArgumentException(ex)
135-
&& lifecycleEvent instanceof AbstractTaskLifecycleEvent) {
136-
// If exception is IllegalArgumentException and the event is task-related
134+
if (ExceptionUtils.isTaskExecutionContextCreateException(ex)) {
135+
// If task initializeTaskExecutionContext before dispatch is failed
137136
// construct and publish a dedicated TaskFatalLifecycleEvent
138137
// so that the event will be handled by TaskFatalLifecycleEventHandler
139138
AbstractTaskLifecycleEvent taskLifecycleEvent = (AbstractTaskLifecycleEvent) lifecycleEvent;

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskSuccessLifecycleEvent;
3737
import org.apache.dolphinscheduler.server.master.engine.task.runnable.ITaskExecutionRunnable;
3838
import org.apache.dolphinscheduler.server.master.engine.workflow.runnable.IWorkflowExecutionRunnable;
39+
import org.apache.dolphinscheduler.server.master.exception.TaskExecutionContextCreateException;
3940

4041
import java.util.concurrent.TimeUnit;
4142

@@ -109,7 +110,14 @@ public void onDispatchEvent(final IWorkflowExecutionRunnable workflowExecutionRu
109110
taskInstance.getDelayTime(),
110111
remainTimeMills);
111112
}
112-
taskExecutionRunnable.initializeTaskExecutionContext();
113+
114+
try {
115+
taskExecutionRunnable.initializeTaskExecutionContext();
116+
} catch (Exception ex) {
117+
log.error("Failed to initialize task execution context, taskName: {}", taskInstance.getName(), ex);
118+
throw new TaskExecutionContextCreateException(ex.getMessage());
119+
120+
}
113121
workerGroupDispatcherCoordinator.dispatchTask(taskExecutionRunnable, remainTimeMills);
114122
}
115123

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/exception/TaskExecutionContextCreateException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.dolphinscheduler.server.master.exception;
1919

20-
public class TaskExecutionContextCreateException extends MasterException {
20+
public class TaskExecutionContextCreateException extends RuntimeException {
2121

2222
public TaskExecutionContextCreateException(String message) {
2323
super(message);

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/ExceptionUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.dolphinscheduler.server.master.utils;
1919

20+
import org.apache.dolphinscheduler.server.master.exception.TaskExecutionContextCreateException;
21+
2022
import org.springframework.dao.DataAccessResourceFailureException;
2123

2224
public class ExceptionUtils {
@@ -25,7 +27,7 @@ public static boolean isDatabaseConnectedFailedException(Throwable e) {
2527
return e instanceof DataAccessResourceFailureException;
2628
}
2729

28-
public static boolean isIllegalArgumentException(Throwable e) {
29-
return e instanceof IllegalArgumentException;
30+
public static boolean isTaskExecutionContextCreateException(Throwable e) {
31+
return e instanceof TaskExecutionContextCreateException;
3032
}
3133
}

0 commit comments

Comments
 (0)