Quick revision
The short answer
Quartz runs a job concurrently with itself whenever a trigger fires while the previous run is still going, unless the job class is annotated @DisallowConcurrentExecution, which in a clustered JDBC store blocks a JobDetail's triggers until the current run ends. The burst after the outage comes from misfire handling: the missed fire times are misfires, and the trigger's misfire instruction, together with org.quartz.jobStore.misfireThreshold, decides whether Quartz fires them all, fires once or skips them. For a 5-minute CronTrigger, MISFIRE_INSTRUCTION_DO_NOTHING skips missed runs and withMisfireHandlingInstructionFireAndProceed fires once and continues.
What to remember
In this answer, we fixed two time-related Quartz problems. Concurrent runs happen because Quartz does not prevent overlap by default; @DisallowConcurrentExecution blocks a JobDetail's triggers while it runs, across a cluster with a JDBC store, and applies per JobDetail rather than per class. The burst after the outage came from misfire handling, either IGNORE_MISFIRE_POLICY or a misfireThreshold so large that missed runs counted as merely late. Choosing DoNothing or FireAndProceed for the CronTrigger, keeping the threshold sensible and checking the stored trigger fixes it, and @PersistJobDataAfterExecution belongs only where the job must update its data map.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Quartz runs a job concurrently with itself whenever a trigger fires while the previous run is still going, unless the job class is annotated @DisallowConcurrentExecution, which in a clustered JDBC store blocks a JobDetail's triggers until the current run ends. The burst after the outage comes from misfire handling: the missed fire times are misfires, and the trigger's misfire instruction, together with org.quartz.jobStore.misfireThreshold, decides whether Quartz fires them all, fires once or skips them. For a 5-minute CronTrigger, MISFIRE_INSTRUCTION_DO_NOTHING skips missed runs and withMisfireHandlingInstructionFireAndProceed fires once and continues.
Why this question is asked
These are two of the most common Quartz surprises, and they often appear together, because both are about time: a run that lasts longer than its interval, and runs that could not happen at their time. Each has a precise cause and a precise fix, but the defaults are not what people expect. Interviewers ask this scenario to see whether we know Quartz's concurrency rules and misfire model rather than guessing. In this answer, we will reproduce the concurrent runs and fix them, then explain misfires, see why an outage can cause a burst, choose a misfire instruction, and look at @PersistJobDataAfterExecution.
1Why the Job Runs Concurrently With Itself
Quartz does not assume that a job must not overlap itself. When a trigger fires, the scheduler takes a free worker thread and runs the job. If the previous run of the same job is still going, for example because it took 7 minutes this time, the new firing simply runs alongside it on another thread, or on another node in a cluster.
So with a 5-minute trigger, any run longer than 5 minutes overlaps the next. Two copies then process the same data, which can mean duplicate work, lock waits between them or, worse, each overwriting the other's results.
2Fix: @DisallowConcurrentExecution
The annotation @DisallowConcurrentExecution on the job class tells Quartz not to run two executions of the same JobDetail at the same time. With a JDBC job store in clustered mode, this holds across all nodes: while one run is going, the JobDetail's triggers are put in a BLOCKED state in the database, and they are released when the run finishes.
Notice two details. The rule is per JobDetail, not per class: if the same class is registered under two JobDetails, for example sync and sync-copy left over from an old configuration, those two can still run in parallel. And a blocked firing that waits longer than the misfire threshold becomes a misfire, which brings us to the second problem.
3What a Misfire Is
A misfire happens when a trigger could not fire at its scheduled time: the scheduler was down, all worker threads were busy, or the job was blocked by @DisallowConcurrentExecution. Quartz does not treat every late firing as a misfire. The property org.quartz.jobStore.misfireThreshold, 60,000 milliseconds by default, says how late a trigger may be and still fire normally. Only when it is later than that does Quartz apply the trigger's misfire instruction.
During a 1-hour outage, a 5-minute trigger misses 12 fire times. When the scheduler comes back, it finds the trigger's next fire time an hour in the past and must decide what to do about it. That decision, not the outage itself, determines whether we get a burst.
4Why the Outage Caused a Burst
There are two usual reasons for many firings at once. The first is the misfire instruction MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, which tells Quartz to ignore misfire handling and fire every missed time as soon as it can, 12 runs back to back. Teams sometimes choose it believing it means 'do not worry about misfires'.
The second is a very large misfireThreshold. If someone set it to two hours to 'avoid misfires', then after a one-hour outage none of the missed firings count as misfires at all: they are all just late, and Quartz fires each of them in turn. A third, less common, cause is that many separate triggers for the same work were added over time, each misfiring and firing once. The default for a CronTrigger, the smart policy, actually fires only once on recovery.
| Setting | What happens at recovery |
|---|---|
IGNORE_MISFIRE_POLICY | fires all 12 missed times back to back |
misfireThreshold of 2 hours | missed times are only late, so all 12 fire |
| smart policy (default) = fire once now | fires once now, then every 5 minutes |
FireAndProceed | fires once now, then every 5 minutes |
DoNothing | no catch-up run, next fire at the next 5-minute mark |
5Choosing the Misfire Instruction
For a job that syncs everything every 5 minutes, running it 12 times after an outage is pointless: one run picks up everything that changed. So we choose explicitly. withMisfireHandlingInstructionDoNothing() skips the missed runs and waits for the next scheduled time; withMisfireHandlingInstructionFireAndProceed() runs once immediately and then continues on schedule. For a frequent sync job, DoNothing is fine; for a job where an hour without a run matters, FireAndProceed gives an immediate catch-up.
But there is a catch with a JDBC store: the misfire instruction is stored with the trigger in the QRTZ_ tables. Changing the bean does not change the stored trigger unless the application is configured to overwrite existing jobs and triggers on startup, so after the fix we should check the MISFIRE_INSTR column in QRTZ_TRIGGERS. For SimpleTriggers, the instructions have different names, such as withMisfireHandlingInstructionNextWithRemainingCount(), which skips missed repeats.
6Where @PersistJobDataAfterExecution Fits
@PersistJobDataAfterExecution tells Quartz to save the JobDataMap back to the job store after each run, so changes the job made to it are seen by the next run. It is sometimes used to store a 'last processed id' between runs. It should almost always be combined with @DisallowConcurrentExecution, because two concurrent runs writing the same data map would overwrite each other.
We should use it only when the job must update its own data map. Storing progress in our own table is usually clearer and easier to inspect, and it keeps the Quartz tables small.
7Follow-up questions
Does @DisallowConcurrentExecution work without clustering?
Yes. On a single scheduler, with RAM or JDBC store, it prevents the same JobDetail running twice in that scheduler. Clustering with a JDBC store extends the guarantee across all nodes, because the blocked state is kept in the shared tables.
Why not just use a long misfireThreshold to be safe?
Because it changes the meaning of late. With a long threshold, missed firings are not treated as misfires, so the misfire instruction we carefully chose is never applied and Quartz fires every late trigger. The default of one minute is usually right; the misfire instruction is where we express what we want.
How do you see misfires happening?
Quartz logs misfire handling, and a TriggerListener's triggerMisfired callback is called for each misfire, which is a good place to count them in a metric. Comparing JobExecutionContext.getScheduledFireTime() with getFireTime() in each run also shows how late jobs start, an early warning before they misfire.
8Conclusion
In this answer, we fixed two time-related Quartz problems. Concurrent runs happen because Quartz does not prevent overlap by default; @DisallowConcurrentExecution blocks a JobDetail's triggers while it runs, across a cluster with a JDBC store, and applies per JobDetail rather than per class. The burst after the outage came from misfire handling, either IGNORE_MISFIRE_POLICY or a misfireThreshold so large that missed runs counted as merely late. Choosing DoNothing or FireAndProceed for the CronTrigger, keeping the threshold sensible and checking the stored trigger fixes it, and @PersistJobDataAfterExecution belongs only where the job must update its data map.
Open with
There are two separate problems. The concurrent runs happen because Quartz doesn't stop a job overlapping itself by default: if a run takes longer than five minutes, the next firing runs alongside it, possibly on another node.
Then, if they want more
Putting @DisallowConcurrentExecution on the job class fixes it; with a clustered JDBC store the JobDetail's triggers are marked blocked in the database while one run is going, so it holds across the cluster. It's per JobDetail, so I'd also check the class isn't registered twice under different keys. The burst is misfire handling.
A firing that's later than misfireThreshold, one minute by default, is a misfire, and the trigger's misfire instruction decides what happens. After an hour down, twelve firings were missed.
The default smart policy for a CronTrigger fires once, so a burst means either the trigger uses IGNORE_MISFIRE_POLICY, which fires all missed times, or someone raised misfireThreshold so high that none counted as misfires and all fired as late.
For a five-minute sync I'd use withMisfireHandlingInstructionDoNothing, or FireAndProceed if one catch-up run matters, keep the threshold at the default, and check the stored MISFIRE_INSTR, since the JDBC store keeps the old value. @PersistJobDataAfterExecution only if the job must update its data map, together with DisallowConcurrentExecution.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Batch reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A Quartz job scheduled every 5 minutes in a clustered JDBC job store sometimes runs...": https://scrivio-interview-library.netlify.app/spring-boot/scheduling/c94cd88dab/