michaelklishin / quartz-mongodb

A MongoDB-based store for the Quartz scheduler. This fork strives to be as feature complete as possible. Originally by MuleSoft.
Other
249 stars 203 forks source link

Jobs are triggered even after the trigger is paused #71

Closed vivganes closed 10 years ago

vivganes commented 10 years ago

I see that jobs are triggered even after trigger is paused.

See a snippet of my code below.

 scheduler.scheduleJob(cronJob,cronTrigger);
 scheduler.pauseTrigger(cronTrigger.getKey());

Even after the trigger has been paused, I see the following lines printed in log.

2014-07-15 18:28:17 DEBUG - Storing job DEFAULT.firstCronJob and trigger DEFAULT.cronTrigger
2014-07-15 18:28:18 DEBUG - Finding up to 1 triggers which have time less than Tue Jul 15 18:28:48 IST 2014
2014-07-15 18:28:18 DEBUG - Found 0 triggers which are eligible to be run.
2014-07-15 18:28:18 DEBUG - batch acquisition of 0 triggers
2014-07-15 18:28:18 DEBUG - Finding up to 1 triggers which have time less than Tue Jul 15 18:28:48 IST 2014
2014-07-15 18:28:18 DEBUG - Found 0 triggers which are eligible to be run.
2014-07-15 18:28:19 DEBUG - batch acquisition of 0 triggers
2014-07-15 18:28:19 DEBUG - Finding up to 1 triggers which have time less than Tue Jul 15 18:28:49 IST 2014
2014-07-15 18:28:19 DEBUG - Found 0 triggers which are eligible to be run.
2014-07-15 18:28:19 DEBUG - batch acquisition of 0 triggers
2014-07-15 18:28:48 DEBUG - Finding up to 1 triggers which have time less than Tue Jul 15 18:29:18 IST 2014
2014-07-15 18:28:48 DEBUG - Found 1 triggers which are eligible to be run.
2014-07-15 18:28:48 DEBUG - Inserting lock for trigger DEFAULT.cronTrigger
2014-07-15 18:28:49 DEBUG - Aquired trigger DEFAULT.cronTrigger
2014-07-15 18:28:49 DEBUG - batch acquisition of 1 triggers
2014-07-15 18:29:00 DEBUG - Fired trigger DEFAULT.cronTrigger
2014-07-15 18:29:00 DEBUG - Producing instance of Job 'DEFAULT.firstCronJob', class=CronJob
2014-07-15 18:29:00 DEBUG - Calling execute on job DEFAULT.firstCronJob
Tue Jul 15 18:29:00 IST 2014: Scheduled Fire Time: Tue Jul 15 18:29:00 IST 2014, Next Fire Time: Tue Jul 15 18:30:00 IST 2014, Fired at : Tue Jul 15 18:29:00 IST 2014
2014-07-15 18:29:00 DEBUG - Trigger completed DEFAULT.cronTrigger
2014-07-15 18:29:02 DEBUG - Removing trigger lock DEFAULT.cronTrigger.NON_CLUSTERED
2014-07-15 18:29:02 DEBUG - Trigger lock DEFAULT.cronTrigger.NON_CLUSTERED removed.
2014-07-15 18:29:02 DEBUG - Finding up to 1 triggers which have time less than Tue Jul 15 18:29:32 IST 2014
2014-07-15 18:29:02 DEBUG - Found 0 triggers which are eligible to be run.
2014-07-15 18:29:02 DEBUG - batch acquisition of 0 triggers

Expectation is that the trigger should not be fired since it has been paused.

The same code works as expected while using RAMJobStore.

michaelklishin commented 10 years ago

I suspect a trigger query somewhere does not include a condition on pausing. Feel free to investigate and submit a pull request with a fix.

huang1900z commented 10 years ago

I add this code in com.novemberain.quartz.mongodb.MongoDBJobStore.doAcquireNextTriggers(),then the paused trigger not be fired .

query.put(TRIGGER_NEXT_FIRE_TIME, new BasicDBObject("$lte", noLaterThanDate));   
query.put(TRIGGER_STATE, STATE_WAITING);//only get waiting trigger
DBCursor cursor = triggerCollection.find(query);
vivganes commented 10 years ago

@huang1900z any pull requests?

huang1900z commented 10 years ago

@vivganes https://github.com/michaelklishin/quartz-mongodb/pull/72

vivganes commented 10 years ago

Thanks a lot

michaelklishin commented 10 years ago

I'll push a new release to Clojars later today.

vivganes commented 10 years ago

Eagerly waiting for a new release...

michaelklishin commented 10 years ago

1.8.0 is up on Clojars.

vivganes commented 10 years ago

Thanks a lot @michaelklishin