ruanwenjun commented on code in PR #10613:
URL: https://github.com/apache/dolphinscheduler/pull/10613#discussion_r907428341
##########
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java:
##########
@@ -192,20 +193,23 @@ public void run() {
sendAlert(this.task.getTaskAlertInfo(),
this.task.getExitStatus().getCode());
}
-
taskExecutionContext.setCurrentExecutionStatus(ExecutionStatus.of(this.task.getExitStatus().getCode()));
- taskExecutionContext.setEndTime(DateUtils.getCurrentDate());
- taskExecutionContext.setProcessId(this.task.getProcessId());
- taskExecutionContext.setAppIds(this.task.getAppIds());
taskExecutionContext.setVarPool(JSONUtils.toJsonString(this.task.getParameters().getVarPool()));
- logger.info("task instance id : {},task final status : {}",
taskExecutionContext.getTaskInstanceId(), this.task.getExitStatus());
+
+ logger.info("task instance id : {}, task final status : {}",
taskExecutionContext.getTaskInstanceId(), this.task.getExitStatus());
} catch (Throwable e) {
- logger.error("task scheduler failure", e);
+ logger.error("task instance id : {}, scheduler failure",
taskExecutionContext.getTaskInstanceId(), e);
+ errorFlag = true;
kill();
-
taskExecutionContext.setCurrentExecutionStatus(ExecutionStatus.FAILURE);
+ } finally {
+ if (errorFlag) {
+
taskExecutionContext.setCurrentExecutionStatus(ExecutionStatus.FAILURE);
+ } else {
+
taskExecutionContext.setCurrentExecutionStatus(ExecutionStatus.of(this.task.getExitStatus().getCode()));
+ }
taskExecutionContext.setEndTime(DateUtils.getCurrentDate());
taskExecutionContext.setProcessId(this.task.getProcessId());
Review Comment:
You can use executionStatus to replace the errorFlag, then you don't need to
deal with the task in finally.
--
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]