现象:

1 [o.q.c.ErrorLogger] - An error occurred while scanning for the next triggers to fire. 2 org.quartz.JobPersistenceException: Couldn't acquire next trigger: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'DEFAULT.6da64b5bd2ee-894279e1-a6bd-4151-bb9d-77acf5647ade' and statement: SELECT * FROM QSMS_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'xxx' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? 3 at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2840) ~[quartz-2.1.5.jar:na] 4 at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2746) ~[quartz-2.1.5.jar:na] 5 at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3811) ~[quartz-2.1.5.jar:na] 6 at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2742) ~[quartz-2.1.5.jar:na] 7 at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264) ~[quartz-2.1.5.jar:na] 8 Caused by: org.quartz.JobPersistenceException: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'DEFAULT.6da64b5bd2ee-894279e1-a6bd-4151-bb9d-77acf5647ade' and statement: SELECT * FROM QSMS_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'xxx' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? 9 at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1524) ~[quartz-2.1.5.jar:na] 10 at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2790) ~[quartz-2.1.5.jar:na] 11 ... 4 common frames omitted 12 Caused by: java.lang.IllegalStateException: No record found for selection of Trigger with key: 'DEFAULT.6da64b5bd2ee-894279e1-a6bd-4151-bb9d-77acf5647ade' and statement: SELECT * FROM QSMS_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'xxx' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? 13 at org.quartz.impl.jdbcjobstore.SimpleTriggerPersistenceDelegate.loadExtendedTriggerProperties(SimpleTriggerPersistenceDelegate.java:95) ~[quartz-2.1.5.jar:na] 14 at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1801) ~[quartz-2.1.5.jar:na] 15 at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1520) ~[quartz-2.1.5.jar:na] 16 ... 5 common frames omitted 17
原因:
是由于Quartzschedulerthread的run方法中出现了竞态条件。
虽然代码中在各处使用了
synchronized(this.sigLock) { //TO DO }
仍然有考虑不全之处。
例如:现在是Quartzschedulerthread第一次扫描将要进行调度的任务,获得10个任务,第一次调度在继续向下处理,但未改变其中某些trigger state时,Quartzschedulerthread进行第二次扫描,导致相同的trigger被扫描出来,此时,第一次调度执行完成,删除掉了执行ok的trigger,而第二次调度在执行同样的trigger时,就会发生,tigger不存在的情况,因为trigger已经被第一次调度给删掉了。
解决方案:
将版本升级到2.2.1,此bug已在2.2.1的版本中修复。不过除了些异常信息外,这些并不构成大的问题。