From 3fedc8c8b8678b196b1a719804f21b1d0b79f4a1 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Sat, 18 Feb 2023 23:41:16 +0800 Subject: [PATCH] cherry-pick Fix task instance will generate multiple times when retry interval is 0/s --- .../server/master/event/TaskStateEventHandler.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 935fa9db37..5f88a1c1f9 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 @@ -59,11 +59,20 @@ 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()); + logger.warn(errorMessage); + throw new StateEventHandleError(errorMessage); + } if (task.getState().isFinished()) { if (completeTaskMap.containsKey(task.getTaskCode()) - && completeTaskMap.get(task.getTaskCode()) == task.getId()) { - logger.warn("The task instance is already complete, stateEvent: {}", stateEvent); + && completeTaskMap.get(task.getTaskCode()).equals(task.getId())) { + logger.warn("The task instance is already complete, stateEvent: {}", stateEvent); return true; } workflowExecuteRunnable.taskFinished(task);