Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quartz Scheduler Executes Multiple Times Despite Fixed Interval and Date Configuration #1227

Open
Git-Mani opened this issue Oct 24, 2024 · 1 comment

Comments

@Git-Mani
Copy link

We have encountered an issue with the Quartz Scheduler where jobs are executing multiple times even after being configured for a fixed time interval and specific date. This behavior is causing duplicate job executions and potential data inconsistencies.

Environment:

  • Quartz Scheduler Version: 2.3.0
  • Database: MongoDB

Scheduler Configuration:

Here are the properties used to instantiate the SchedulerFactoryBean:

properties.setProperty("org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread", "true");
properties.setProperty("org.quartz.jobStore.class", "com.novemberain.quartz.mongodb.MongoDBJobStore");
properties.setProperty("org.quartz.jobStore.mongoUri", "mongoUri");
properties.setProperty("org.quartz.jobStore.dbName", "mongoDatabase");
properties.setProperty("org.quartz.jobStore.collectionPrefix", "quartz-entry");
properties.setProperty("org.quartz.threadPool.threadCount", "5");

Trigger Configuration:

The trigger is configured as follows:

Date startDate = new SimpleDateFormat("yyyy-MM-dd").parse(req.getSchedule().getStartDate());
Date endDate = new SimpleDateFormat("yyyy-MM-dd").parse(req.getSchedule().getEndDate());

SimpleTrigger cronTrigger = TriggerBuilder.newTrigger()
        .withIdentity("trigger", req.getId() + "_" + req.getName())
        .startAt(startDate)
        .endAt(endDate)
        .withSchedule(simpleSchedule()
                .withIntervalInMinutes(req.getSchedule().getIntervalMinutes())
                .withMisfireHandlingInstructionFireNow()
                .repeatForever())
        .build();

Expected Behavior: The job should execute only once according to the specified schedule, without any duplicate executions.

Actual Behavior: Jobs are executing multiple times.

The issue occurs infrequently and has not been observed in the local environment.

Any assistance in identifying the root cause of this issue or advice on debugging and preventing these rare occurrences of multiple executions would be greatly appreciated. If anyone has encountered similar behavior with Quartz Scheduler or can suggest troubleshooting steps, please share your insights.

@jhouserizer
Copy link
Contributor

Hi!
Not aware of any similar problem reports, and thinking what could cause the issue makes me think of transaction isolation issues as a likely culprit. Then looking at your config, you have this: properties.setProperty("org.quartz.jobStore.class", "com.novemberain.quartz.mongodb.MongoDBJobStore"); -- which means the thing you have doing the work around transactions is not something that is part of Quartz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants