Fix Quartz Scheduler Race Condition (#4607)

* fix

* clean up
This commit is contained in:
Nathan Doef 2023-03-13 11:02:42 -04:00 committed by GitHub
parent d1f9c94038
commit 5f74396bfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 4617
title: "Previously, Quartz jobs were scheduled after the scheduler was started which resulted in a race
condition where duplicate `TRIGGER_ACCESS` entries were being added to the `QRTZ_LOCKS` table.
This has been fixed."

View File

@ -145,6 +145,14 @@ public abstract class BaseSchedulerServiceImpl implements ISchedulerService {
@EventListener(ContextRefreshedEvent.class) @EventListener(ContextRefreshedEvent.class)
public void start() { public void start() {
// Jobs are scheduled first to avoid a race condition that occurs if jobs are scheduled
// after the scheduler starts for the first time. This race condition results in duplicate
// TRIGGER_ACCESS entries being added to the QRTZ_LOCKS table.
// Note - Scheduling jobs before the scheduler has started is supported by Quartz
// http://www.quartz-scheduler.org/documentation/quartz-2.3.0/cookbook/CreateScheduler.html
scheduleJobs();
myStopping.set(false); myStopping.set(false);
try { try {
@ -159,8 +167,6 @@ public abstract class BaseSchedulerServiceImpl implements ISchedulerService {
ourLog.error("Failed to start scheduler", e); ourLog.error("Failed to start scheduler", e);
throw new ConfigurationException(Msg.code(1632) + "Failed to start scheduler", e); throw new ConfigurationException(Msg.code(1632) + "Failed to start scheduler", e);
} }
scheduleJobs();
} }
private void scheduleJobs() { private void scheduleJobs() {