[I18N-1560] Fix Quartz from getting into a blocked state if ScheduledJobListener throws - #496
Merged
Merged
Conversation
vnpins
approved these changes
Jul 29, 2026
maallen
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Quartz aborts all remaining listener notifications for a job the moment one listener throws.
ScheduledJobListener.jobWasExecutedpersists the job's completion status (success/failure) back to the database - if itthrows (e.g. a transient DB error), that notification is dropped and the job's row is left stuck in
IN_PROGRESS/BLOCKEDstate forever, even though it actually finished. It then never gets picked up again by the scheduler.Solution
The solution here is to ensure nothing in the
jobWasExecutedmethod throws which stops Quartz from sending the "job has finished" notification to the db. This PR ensures any exceptions are captured in the listener and does retries with exponential backoff.Concern
Another concern was if the db is actually down for something like maintenance (e.g version upgrade) even if we don't throw in the
jobWasExecuted, wouldn't Quartz not be able to send the notification to the db saying the "job has finished" also causing the equivalent issue with the job being forever in a BLOCKED state?The answer to this is Quartz will retry every 15 seconds by default to report the job status back to the db infinitely, more info here under the
org.quartz.scheduler.dbFailureRetryIntervalproperty: https://www.quartz-scheduler.org/documentation/quartz-2.2.2/configuration/ConfigMain.htmlTesting
All of this was tested locally by stopping the local MySQL instance during job execution to simulate the blocked state. The retries take place and Quartz successfully unblocks itself when the db comes back up.