-
Notifications
You must be signed in to change notification settings - Fork 38.5k
CronTrigger is not triggered at correct time [SPR-7004] #11669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented I can't reproduce this, unfortunately: Even on Windows XP and JDK 1.6.0, CronTrigger fires exactly every 5 minutes for me. Are there any special characteristics of your environment which might influence the triggering here? Juergen |
adi ofry commented My colleague reproduced it on windows machine. It doesn't happen on our Linux server. |
Gabriel Forro commented Recently I have played with the TaskScheduler and I have met this reported bug in the CronTrigger also. Task executions are duplicated (even triplicated) in a non deterministic way. The following rules can be applied:
Comments to different environments, which I have tried:
I have attached a simple project (spr-7004.zip), which demonstrates the problem. |
Gabriel Forro commented Simple project which demonstrates spr-7004 |
Christophe Roudet commented It happens when the task last less than one second, then you can have TriggerContext.lastActualExecutionTime and TriggerContext.lastActualExecutionTime equals seconds wise.
|
Juergen Hoeller commented Hmm, CronSequenceGenerator increases the incoming date to the next full second already: calendar.add(Calendar.SECOND, 1); This should prevent double-fires for the same second as-is, shouldn't it. Juergen |
Christophe Roudet commented You are right for the adjustment to the next second. It looks like the job can be fired a few milliseconds before its scheduled time, so it can also ends before its scheduled time. |
Juergen Hoeller commented Good catch! lastCompletionTime being before lastScheduledExecutionTime might well be the problem here, and certainly explains the observations above. I've also been able to reproduce the effect by artifically running tasks too early. As a consequence, CronTrigger defensively protects itself against accidental re-fires if the previous task ran too early now. This will be available in tomorrow's 3.0.3 snapshot; feel free to give it an early try... Juergen |
adi ofry opened SPR-7004 and commented
When running CronTrigger on short interval I get the task triggered sooner then requested and also get duplicates.
public void initScheduler() {
System.out.println("Got initScheduler");
taskExecutor = new ThreadPoolTaskScheduler();
taskExecutor.initialize();
}
The output is:
Got initScheduler
Thu Mar 18 17:08:19 IST 2010
Thu Mar 18 17:08:24 IST 2010
Thu Mar 18 17:08:24 IST 2010
Thu Mar 18 17:08:25 IST 2010
Thu Mar 18 17:08:29 IST 2010
Thu Mar 18 17:08:30 IST 2010
Affects: 3.0.1
Attachments:
Issue Links:
Referenced from: commits dea5918
The text was updated successfully, but these errors were encountered: