Browse Source

Fix when update scheduler will execute workflow (#13285)

(cherry picked from commit df32ef0efb)
3.0.5-release
Wenjun Ruan 2 years ago committed by Jay Chung
parent
commit
5ad601bacb
  1. 13
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
  2. 13
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/impl/QuartzExecutorImpl.java

13
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);
}

13
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)) {

Loading…
Cancel
Save