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

Rescheduling Non-Durable Job Breaks #44

Closed lordbuddha closed 10 years ago

lordbuddha commented 10 years ago

If you have a job with a single trigger, and during the execution of that job you make a call to reschedule that job, the code fails because replaceTrigger calls removeTrigger which also deletes the associated job if that was the only trigger associated with the job and it was not durable.

So, in replaceTrigger,

replace

removeTrigger(triggerKey);

With

BasicDBObject dbObject = Keys.keyToDBObject(triggerKey);
DBCursor triggers = triggerCollection.find(dbObject);
if (triggers.count() > 0) {
  triggerCollection.remove(dbObject);
}

It might be worth considering adding an appropriate lock around the remove of the old trigger and the adding of the new.

michaelklishin commented 10 years ago

@lordbuddha please submit pull requests instead of posting code snippets.

lordbuddha commented 10 years ago

Hi, I would but am rushed off feet at the moment ...

Will see what I can do.

On 9 November 2013 12:57, Michael Klishin notifications@github.com wrote:

@lordbuddha https://github.com/lordbuddha please submit pull requests instead of posting code snippets.

— Reply to this email directly or view it on GitHubhttps://github.com/michaelklishin/quartz-mongodb/issues/44#issuecomment-28108106 .

michaelklishin commented 10 years ago

Should be fixed in a3917a5651aa419b8fc717b07419eb62c14ff5ba.