You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2023/10/11 08:06:37 UTC
[dolphinscheduler] 35/40: Fix task log appender will not be closed immediate after throwing exception (#14989)
This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch 3.2.0-release
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
commit 512f94070a8ebeaf65bd9f159d488254484239ef
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Sun Oct 8 09:19:02 2023 +0800
Fix task log appender will not be closed immediate after throwing exception (#14989)
(cherry picked from commit 629fced9efa0724463bcfe9410486d79af482a2a)
---
.../server/master/runner/execute/MasterTaskExecuteRunnable.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/execute/MasterTaskExecuteRunnable.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/execute/MasterTaskExecuteRunnable.java
index 8abcebc48e..242e3c723f 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/execute/MasterTaskExecuteRunnable.java
+++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/execute/MasterTaskExecuteRunnable.java
@@ -56,9 +56,10 @@ public abstract class MasterTaskExecuteRunnable implements Runnable {
protected abstract void afterExecute() throws MasterTaskExecuteException;
protected void afterThrowing(Throwable throwable) {
+ TaskInstanceLogHeader.printFinalizeTaskHeader();
try {
+ log.error("Get a exception when execute the task, will try to cancel the task", throwable);
cancelTask();
- log.error("Get a exception when execute the task, canceled the task", throwable);
} catch (Exception e) {
log.error("Cancel task failed,", e);
}
@@ -70,6 +71,7 @@ public abstract class MasterTaskExecuteRunnable implements Runnable {
MasterTaskExecutionContextHolder.removeTaskExecutionContext(taskExecutionContext.getTaskInstanceId());
MasterTaskExecuteRunnableHolder.removeMasterTaskExecuteRunnable(taskExecutionContext.getTaskInstanceId());
log.info("Get a exception when execute the task, removed the TaskExecutionContext");
+ closeLogAppender();
}
public void cancelTask() throws MasterTaskExecuteException {
@@ -112,7 +114,6 @@ public abstract class MasterTaskExecuteRunnable implements Runnable {
} catch (Throwable ex) {
log.error("Task execute failed, due to meet an exception", ex);
afterThrowing(ex);
- closeLogAppender();
} finally {
LogUtils.removeWorkflowAndTaskInstanceIdMDC();
LogUtils.removeTaskInstanceLogFullPathMDC();