This is an automated email from the ASF dual-hosted git repository.
gallardot pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 1317e837ff [Bug] Refresh restart time when failover a workflow
instance (#17344)
1317e837ff is described below
commit 1317e837ff14597c619e517926247dba7231d0d7
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sun Jul 20 01:11:09 2025 +0800
[Bug] Refresh restart time when failover a workflow instance (#17344)
Co-authored-by: xiangzihao <[email protected]>
---
.../org/apache/dolphinscheduler/server/master/MasterServer.java | 7 ++++---
.../engine/command/handler/WorkflowFailoverCommandHandler.java | 2 ++
.../server/master/failover/FailoverCoordinator.java | 4 ++--
.../master/integration/cases/WorkflowInstanceFailoverTestCase.java | 2 +-
.../apache/dolphinscheduler/registry/api/utils/RegistryUtils.java | 2 +-
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
index f0dfdd70e2..3a23ddf881 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
@@ -117,7 +117,6 @@ public class MasterServer implements IStoppable {
@PostConstruct
public void initialized() {
ServerLifeCycleManager.toRunning();
- final long startupTime = System.currentTimeMillis();
// init rpc server
this.masterRPCServer.start();
@@ -140,7 +139,8 @@ public class MasterServer implements IStoppable {
this.schedulerApi.start();
- this.systemEventBus.publish(GlobalMasterFailoverEvent.of(new
Date(startupTime)));
+ this.systemEventBus
+ .publish(GlobalMasterFailoverEvent.of(new
Date(ServerLifeCycleManager.getServerStartupTime())));
this.systemEventBusFireWorker.start();
MasterServerMetrics.registerMasterCpuUsageGauge(() -> {
@@ -161,7 +161,8 @@ public class MasterServer implements IStoppable {
close("MasterServer shutdownHook");
}
}));
- log.info("MasterServer initialized successfully in {} ms",
System.currentTimeMillis() - startupTime);
+ log.info("MasterServer initialized successfully in {} ms",
+ System.currentTimeMillis() -
ServerLifeCycleManager.getServerStartupTime());
}
@PreDestroy
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/command/handler/WorkflowFailoverCommandHandler.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/command/handler/WorkflowFailoverCommandHandler.java
index 45716ec1dd..093d61e26e 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/command/handler/WorkflowFailoverCommandHandler.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/command/handler/WorkflowFailoverCommandHandler.java
@@ -33,6 +33,7 @@ import
org.apache.dolphinscheduler.server.master.engine.task.runnable.TaskExecut
import
org.apache.dolphinscheduler.server.master.engine.task.runnable.TaskExecutionRunnableBuilder;
import
org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteContext.WorkflowExecuteContextBuilder;
+import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
@@ -89,6 +90,7 @@ public class WorkflowFailoverCommandHandler extends
AbstractCommandHandler {
throw new IllegalArgumentException(
"The WorkflowFailoverCommandParam: " +
command.getCommandParam() + " is invalid");
}
+ workflowInstance.setRestartTime(new Date());
workflowInstance.setState(workflowFailoverCommandParam.getWorkflowExecutionStatus());
workflowInstance.setHost(masterConfig.getMasterAddress());
workflowInstanceDao.updateById(workflowInstance);
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
index 30a9ae773b..6935e41622 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/FailoverCoordinator.java
@@ -83,7 +83,7 @@ public class FailoverCoordinator implements
IFailoverCoordinator {
doMasterFailover(
masterAddress,
aliveMasterServerMetadata.getServerStartupTime(),
-
RegistryUtils.getFailoveredNodePathWhichStartupTimeIsUnknown(
+ RegistryUtils.getGlobalMasterFailoverNodePath(
masterAddress));
} else {
// If the master is not alive, then we use the event time as
the failover deadline.
@@ -91,7 +91,7 @@ public class FailoverCoordinator implements
IFailoverCoordinator {
doMasterFailover(
masterAddress,
globalMasterFailoverEvent.getEventTime().getTime(),
-
RegistryUtils.getFailoveredNodePathWhichStartupTimeIsUnknown(masterAddress));
+
RegistryUtils.getGlobalMasterFailoverNodePath(masterAddress));
}
}
diff --git
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
index 8b0269eac2..2967109ac9 100644
---
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
+++
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
@@ -568,7 +568,7 @@ public class WorkflowInstanceFailoverTestCase extends
AbstractMasterIntegrationT
systemEventBus.publish(GlobalMasterFailoverEvent.of(new Date()));
- final String masterFailoverNodePath =
RegistryUtils.getFailoveredNodePathWhichStartupTimeIsUnknown(
+ final String masterFailoverNodePath =
RegistryUtils.getGlobalMasterFailoverNodePath(
"127.0.0.1:15678");
// wait failover process
await()
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/utils/RegistryUtils.java
b/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/utils/RegistryUtils.java
index 7edcce3c84..da7d488549 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/utils/RegistryUtils.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/utils/RegistryUtils.java
@@ -29,7 +29,7 @@ public class RegistryUtils {
return RegistryNodeType.MASTER_FAILOVER_LOCK.getRegistryPath() + "/" +
masterAddress;
}
- public static String getFailoveredNodePathWhichStartupTimeIsUnknown(final
String serverAddress) {
+ public static String getGlobalMasterFailoverNodePath(final String
serverAddress) {
return RegistryNodeType.FAILOVER_FINISH_NODES.getRegistryPath() + "/"
+ serverAddress + "-" + "unknown" + "-"
+ "unknown";
}