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
250 stars 202 forks source link

Scheduler cannot remove own expired lock in case of certain MongoDB client exceptions #196

Closed zero-devourer closed 4 years ago

zero-devourer commented 4 years ago

DESC: When expire the lock , mongo has a exception (such as connection time out) . Then the lock cannot be expired. And this job will no longer be triggered. REASON: the code in ExpiryCalculator.class ` public boolean isTriggerLockExpired(Document lock) { String schedulerId = lock.getString(Constants.LOCK_INSTANCE_ID); return isLockExpired(lock, triggerTimeoutMillis) && hasDefunctScheduler(schedulerId); }

private boolean hasDefunctScheduler(String schedulerId) { Scheduler scheduler = schedulerDao.findInstance(schedulerId); if (scheduler == null) { log.debug("No such scheduler: {}", schedulerId); return false; } return scheduler.isDefunct(clock.millis()) && schedulerDao.isNotSelf(scheduler); } If scheduler is not defunct ,the function (isTriggerLockExpired())s result will always be false. And the job which was locked will nerver be triggered.

michaelklishin commented 4 years ago

@Zero-devourer please submit a PR since you understand the problem.