You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2023/03/30 10:27:09 UTC

[dolphinscheduler] 03/07: Fix when update scheduler will execute workflow (#13285)

This is an automated email from the ASF dual-hosted git repository.

zhongjiajie pushed a commit to branch 3.0.5-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git

commit 5ad601bacb3cbead223209c1a1af6e98b709b2a3
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Wed Dec 28 14:33:38 2022 +0800

    Fix when update scheduler will execute workflow (#13285)
    
    (cherry picked from commit df32ef0efb20641a228b999c625f7c3db989b97b)
---
 .../api/controller/SchedulerController.java                 | 13 +++++++++++--
 .../service/quartz/impl/QuartzExecutorImpl.java             | 13 ++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
index 03e8db63c3..0e02ada39d 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@@ -116,8 +116,17 @@ public class SchedulerController extends BaseController {
                                  @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
                                  @RequestParam(value = "environmentCode", required = false, defaultValue = "-1") Long environmentCode,
                                  @RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
-        Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, schedule,
-            warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode);
+        Map<String, Object> result = schedulerService.insertSchedule(
+                loginUser,
+                projectCode,
+                processDefinitionCode,
+                schedule,
+                warningType,
+                warningGroupId,
+                failureStrategy,
+                processInstancePriority,
+                workerGroup,
+                environmentCode);
 
         return returnDataList(result);
     }
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/impl/QuartzExecutorImpl.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/impl/QuartzExecutorImpl.java
index 78e12717d1..2c187becf5 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/impl/QuartzExecutorImpl.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/impl/QuartzExecutorImpl.java
@@ -87,6 +87,14 @@ public class QuartzExecutorImpl implements QuartzExecutor {
          */
         Date startDate = DateUtils.transformTimezoneDate(schedule.getStartTime(), timezoneId);
         Date endDate = DateUtils.transformTimezoneDate(schedule.getEndTime(), timezoneId);
+        /**
+         * If the start time is less than the current time, the start time is set to the current time.
+         * We do this change to avoid misfires all triggers when update the scheduler.
+         */
+        Date now = new Date();
+        if (startDate.before(now)) {
+            startDate = now;
+        }
 
         lock.writeLock().lock();
         try {
@@ -123,9 +131,8 @@ public class QuartzExecutorImpl implements QuartzExecutor {
                     .endAt(endDate)
                     .withSchedule(
                             cronSchedule(cronExpression)
-                                    .withMisfireHandlingInstructionFireAndProceed()
-                                    .inTimeZone(DateUtils.getTimezone(timezoneId))
-                    )
+                                    .withMisfireHandlingInstructionIgnoreMisfires()
+                                    .inTimeZone(DateUtils.getTimezone(timezoneId)))
                     .forJob(jobDetail).build();
 
             if (scheduler.checkExists(triggerKey)) {