From 11466c934fdd3ad47371b099e0d1db975709ef42 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 19 Jan 2023 09:46:18 +0800 Subject: [PATCH] [Fix-13283][Master] Worker failover cause task repeat run (#13403) * [Fix-13283][Master] Worker failover cause task repeat run * [Fix-13283][Master] Worker failover cause task repeat run rename variable * [Fix-13283][Master] Worker failover cause task repeat run format datetime of log --- .../master/registry/MasterRegistryClient.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java index 906952e709..ed6b29f076 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java @@ -29,6 +29,7 @@ import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.thread.ThreadUtils; +import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; @@ -317,11 +318,14 @@ public class MasterRegistryClient { return false; } - Date taskTime = taskInstance.getStartTime() == null ? taskInstance.getSubmitTime() : taskInstance.getStartTime(); - - Date serverStartDate = getServerStartupTime(servers, taskInstance.getHost()); - if (serverStartDate != null) { - return taskTime.after(serverStartDate); + Date taskSubmitTime = taskInstance.getSubmitTime(); + Date serverStartTime = getServerStartupTime(servers, taskInstance.getHost()); + if (taskSubmitTime != null && serverStartTime != null && taskSubmitTime.after(serverStartTime)) { + logger.info( + "The taskInstance's submitTime: {} is after the need failover server's start time: {}, the taskInstance is newly submit, it doesn't need to failover", + DateUtils.dateToString(taskSubmitTime), + DateUtils.dateToString(serverStartTime)); + return true; } return false; }