Browse Source

Fix when update scheduler will execute workflow (#13285)

3.2.0-release
Wenjun Ruan 2 years ago committed by GitHub
parent
commit
df32ef0efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
  2. 10
      dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java

@ -115,9 +115,17 @@ public class SchedulerController extends BaseController {
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "environmentCode", required = false, defaultValue = "-1") Long environmentCode, @RequestParam(value = "environmentCode", required = false, defaultValue = "-1") Long environmentCode,
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) { @RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, Map<String, Object> result = schedulerService.insertSchedule(
loginUser,
projectCode,
processDefinitionCode,
schedule, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode); warningType,
warningGroupId,
failureStrategy,
processInstancePriority,
workerGroup,
environmentCode);
return returnDataList(result); return returnDataList(result);
} }

10
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/QuartzScheduler.java

@ -77,6 +77,14 @@ public class QuartzScheduler implements SchedulerApi {
*/ */
Date startDate = DateUtils.transformTimezoneDate(schedule.getStartTime(), timezoneId); Date startDate = DateUtils.transformTimezoneDate(schedule.getStartTime(), timezoneId);
Date endDate = DateUtils.transformTimezoneDate(schedule.getEndTime(), 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(); lock.writeLock().lock();
try { try {
@ -109,7 +117,7 @@ public class QuartzScheduler implements SchedulerApi {
.endAt(endDate) .endAt(endDate)
.withSchedule( .withSchedule(
cronSchedule(cronExpression) cronSchedule(cronExpression)
.withMisfireHandlingInstructionFireAndProceed() .withMisfireHandlingInstructionIgnoreMisfires()
.inTimeZone(DateUtils.getTimezone(timezoneId))) .inTimeZone(DateUtils.getTimezone(timezoneId)))
.forJob(jobDetail).build(); .forJob(jobDetail).build();

Loading…
Cancel
Save