diff --git a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManager.java b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManager.java index f64279ccbe..54ad75f57d 100644 --- a/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManager.java +++ b/kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManager.java @@ -97,6 +97,7 @@ public void onChange(final DataChangedEvent event) { if (!failoverItems.isEmpty()) { for (int each : failoverItems) { failoverService.setCrashedFailoverFlagDirectly(each); + executionService.clearRunningInfo(Collections.singletonList(each)); failoverService.failoverIfNecessary(); } } else { diff --git a/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManagerTest.java b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManagerTest.java index a5dfafa4c5..5bfe27dee7 100644 --- a/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManagerTest.java +++ b/kernel/src/test/java/org/apache/shardingsphere/elasticjob/kernel/internal/failover/FailoverListenerManagerTest.java @@ -157,6 +157,7 @@ void assertJobCrashedJobListenerWhenIsOtherFailoverInstanceCrashed() { when(instanceNode.getInstanceFullPath()).thenReturn("/test_job/instances"); failoverListenerManager.new JobCrashedJobListener().onChange(new DataChangedEvent(Type.DELETED, "/test_job/instances/127.0.0.1@-@1", "")); verify(failoverService).setCrashedFailoverFlagDirectly(1); + verify(executionService).clearRunningInfo(Collections.singletonList(1)); verify(failoverService).failoverIfNecessary(); JobRegistry.getInstance().shutdown("test_job"); }