CDV ❯ Scheduler.unscheduleJob and Scheduler.deleteJob do not work with TerracottaJobStore
-
Bug
-
Status: Closed
-
1 Critical
-
Resolution: Fixed
-
-
-
-
Reporter: vladnc
-
February 11, 2010
-
0
-
Watchers: 1
-
March 05, 2010
-
February 16, 2010
Attachments
Description
I started testing the Quartz Scheduler for performance, first with RAM Store, then with JDBC Store Cluster, and finally with TerracottaJobStore.
I was not able to complete the TerracottaJobStore tests, due to the bug.
I used Windows 7 x64, jdk1.6.0_17 64-Bit, and Terracotta 3.2.0 without permanent-store.
Within a test class, I scheduled a few hundred jobs with SimpleTrigger, with start times distributed randomly within one minute, and no repeat.
I started the scheduler, and everything went fine, the jobs ran at their scheduled time. I stopped the application with End Process from task manager.
Then I tried to run the application again, without restarting the Terracotta server, but I received this error:
Exception in thread “main” org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: ‘test’ and group: ‘test’, because one already exists with this identification. at org.terracotta.quartz.ClusteredJobStore.storeJob(ClusteredJobStore.java:329) at org.terracotta.quartz.ClusteredJobStore.storeJobAndTrigger(ClusteredJobStore.java:305) at org.terracotta.quartz.PlainTerracottaJobStore.storeJobAndTrigger(PlainTerracottaJobStore.java:196) at org.terracotta.quartz.TerracottaJobStore.storeJobAndTrigger(TerracottaJobStore.java:513) at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:743) at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:243) at ro.objects.quartz.test.TerracottaQuartzBug.main(TerracottaQuartzBug.java:38)
This didn’t happen when I used an Oracle database as the store. The jobs were cleared from the database after the jobs were executed. I don’t know if this is another bug, or the intended behaviour, but I attempted to find a workaround, so I added a deleteJob call before scheduling, to remove any old jobs with the same name as the new jobs, like this:
scheduler.deleteJob("test", "test");
I tried to run the test again, but I received a different exception:
Exception in thread “main” org.quartz.ObjectAlreadyExistsException: Unable to store Trigger with name: ‘test’ and group: ‘test’, because one already exists with this identification. at org.terracotta.quartz.ClusteredJobStore.storeTrigger(ClusteredJobStore.java:403) at org.terracotta.quartz.ClusteredJobStore.storeJobAndTrigger(ClusteredJobStore.java:306) at org.terracotta.quartz.PlainTerracottaJobStore.storeJobAndTrigger(PlainTerracottaJobStore.java:196) at org.terracotta.quartz.TerracottaJobStore.storeJobAndTrigger(TerracottaJobStore.java:513) at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:743) at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:243) at ro.objects.quartz.test.TerracottaQuartzBug.main(TerracottaQuartzBug.java:38)
The job was deleted, but the trigger remained, although the JavaDoc specifies that deleteJob should delete both the job and the trigger:
boolean deleteJob(String jobName, String groupName) throws SchedulerException - Delete the identified Job from the Scheduler - and any associated Triggers.
So, after also restarting the Terracotta server and running the application successfully one time, I tried to delete the trigger before deleting the job, to workaround the new bug, adding a new line before the deleteJob line:
scheduler.unscheduleJob("test", "test");
scheduler.deleteJob("test", "test");
And, of course, I received a new exception:
Exception in thread “main” java.lang.NullPointerException at org.terracotta.quartz.ClusteredJobStore.removeTrigger(ClusteredJobStore.java:483) at org.terracotta.quartz.ClusteredJobStore.removeTrigger(ClusteredJobStore.java:450) at org.terracotta.quartz.PlainTerracottaJobStore.removeTrigger(PlainTerracottaJobStore.java:136) at org.terracotta.quartz.TerracottaJobStore.removeTrigger(TerracottaJobStore.java:445) at org.quartz.core.QuartzScheduler.unscheduleJob(QuartzScheduler.java:863) at org.quartz.impl.StdScheduler.unscheduleJob(StdScheduler.java:290) at ro.objects.quartz.test.TerracottaQuartzBug.main(TerracottaQuartzBug.java:31)
I restarted the Terracotta server and repeated the tests but now I called deleteJob before calling unscheduleJob, like this:
scheduler.deleteJob("test", "test");
scheduler.unscheduleJob("test", "test");
I received the same NullPointerException.
So it seems there is no way to delete the trigger (which should have probably deleted itself after the job execution anyway), except restarting the Terracotta server. And probably restarting it would not have helped if I had configured a permanent store for Terracotta.
I attached a class that reproduces the bug, and the Terracotta cluster configuration file.
Comments
Tim Eck 2010-02-12
Tim Eck 2010-02-12
If you’d be interested in getting a preview release of 3.2.1 to test with, please let me know via email:
teck
I’d appreciate if you could test it out and make sure your tests work okay with it
Tim Eck 2010-02-16
Marking this as resolved for now. No response on taking a a 3.2.1 preview
This is a bug in the clustered quartz job store. It is not tied to core quartz release. moving to CDV project for target Darwin
Himadri Singh 2010-02-24
w/ 3.2.0
2010-02-24 16:51:29,609 INFO [org.quartz.simpl.SimpleThreadPool] - Job execution threads will use class loader of thread: main 2010-02-24 16:51:29,671 INFO [org.quartz.core.SchedulerSignalerImpl] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl 2010-02-24 16:51:29,671 INFO [org.quartz.core.QuartzScheduler] - Quartz Scheduler v.1.7.1 created. 2010-02-24 16:51:37,656 INFO - Terracotta 3.2.0, as of 20091212-151212 (Revision 14206 by cruise@su10mo5 from 3.2) 2010-02-24 16:51:38,031 INFO - Configuration loaded from the server at ‘localhost:9510’. 2010-02-24 16:51:38,093 INFO - Configuration loaded from the file at ‘C:\DOCUME~1\hsingh\LOCALS~1\Temp\tc-config3088949704360541785.xml’. 2010-02-24 16:51:45,343 INFO - Log file: ‘C:\eclispe-workspaces\quartz\test-sample\terracotta\client-logs\terracotta-client.log’. 2010-02-24 16:51:54,687 INFO - Connection successfully established to server at 10.0.7.69:9510 2010-02-24 16:51:55,328 INFO [org.terracotta.quartz.ClusteredJobStore] - ClusteredJobStore initialized. 2010-02-24 16:51:55,328 INFO [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler ‘DefaultQuartzScheduler’ initialized from default resource file in Quartz package: ‘quartz.properties’ 2010-02-24 16:51:55,328 INFO [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler version: 1.7.1 Exception in thread “main” java.lang.NullPointerException at org.terracotta.quartz.ClusteredJobStore.removeTrigger(ClusteredJobStore.java:483) at org.terracotta.quartz.ClusteredJobStore.removeTrigger(ClusteredJobStore.java:450) at org.terracotta.quartz.PlainTerracottaJobStore.removeTrigger(PlainTerracottaJobStore.java:136) at org.terracotta.quartz.TerracottaJobStore.removeTrigger(TerracottaJobStore.java:445) at org.quartz.core.QuartzScheduler.unscheduleJob(QuartzScheduler.java:853) at org.quartz.impl.StdScheduler.unscheduleJob(StdScheduler.java:290) at org.terracotta.quartz.TerracottaQuartzBug.main(TerracottaQuartzBug.java:31)
w/ 3.2.1 2010-02-24 17:11:05,984 INFO [org.quartz.simpl.SimpleThreadPool] - Job execution threads will use class loader of thread: main 2010-02-24 17:11:06,000 INFO [org.quartz.core.SchedulerSignalerImpl] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl 2010-02-24 17:11:06,000 INFO [org.quartz.core.QuartzScheduler] - Quartz Scheduler v.1.7.3 created. 2010-02-24 17:11:06,781 INFO - Terracotta 3.2.1, as of 20100223-170218 (Revision 14620 by cruise@su10mo5 from 3.2) 2010-02-24 17:11:07,125 INFO - Configuration loaded from the server at ‘localhost:9510’. 2010-02-24 17:11:07,187 INFO - Configuration loaded from the file at ‘C:\DOCUME~1\hsingh\LOCALS~1\Temp\tc-config2902556757456273231.xml’. 2010-02-24 17:11:07,281 INFO - Log file: ‘C:\eclispe-workspaces\quartz\test-sample\terracotta\client-logs\terracotta-client.log’. 2010-02-24 17:11:08,500 INFO - Connection successfully established to server at 10.0.7.69:9510 2010-02-24 17:11:09,109 INFO [org.terracotta.quartz.ClusteredJobStore] - ClusteredJobStore initialized. 2010-02-24 17:11:09,109 INFO [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler ‘DefaultQuartzScheduler’ initialized from default resource file in Quartz package: ‘quartz.properties’ 2010-02-24 17:11:09,109 INFO [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler version: 1.7.3 2010-02-24 17:11:09,687 INFO [org.quartz.core.QuartzScheduler] - Scheduler DefaultQuartzScheduler_$_HSINGHPC1267011665968 started. Hello World
Verified.
Thanks for the report. I think I have figured out what is going wrong, the issue is actually with the underlying map component that tim-quartz uses for storing job data. The fix for that issue (DEV-3735) will be present in Terracotta 3.2.1
Running the example program with a 3.2.1 development build does not throw the NullPointerException.