From e8b20def544a203bb9c927e19dae531b6f98d512 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Sat, 18 Feb 2023 23:41:16 +0800 Subject: [PATCH] Fix task instance will generate multiple times when retry interval is 0/s (#13571) --- .../server/master/event/TaskStateEventHandler.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java index 676e7c37a8..7a6e0c3072 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java @@ -57,10 +57,19 @@ public class TaskStateEventHandler implements StateEventHandler { task.getState(), taskStateEvent.getStatus()); Map completeTaskMap = workflowExecuteRunnable.getCompleteTaskMap(); + if (task.getState().isFinished() + && (taskStateEvent.getStatus() != null && taskStateEvent.getStatus().isRunning())) { + String errorMessage = String.format( + "The current task instance state is %s, but the task state event status is %s, so the task state event will be ignored", + task.getState(), + taskStateEvent.getStatus()); + log.warn(errorMessage); + throw new StateEventHandleError(errorMessage); + } if (task.getState().isFinished()) { if (completeTaskMap.containsKey(task.getTaskCode()) - && completeTaskMap.get(task.getTaskCode()) == task.getId()) { + && completeTaskMap.get(task.getTaskCode()).equals(task.getId())) { log.warn("The task instance is already complete, stateEvent: {}", stateEvent); return true; }