石英调度程序无法获取触发器

Posted

技术标签:

【中文标题】石英调度程序无法获取触发器【英文标题】:quartz scheduler cannot acquire trigger 【发布时间】:2017-05-18 07:12:40 【问题描述】:

我正在与一位客户合作,但遇到了不时触发作业的问题。

这里是一个错误示例,这种情况经常发生,也会导致作业无法触发。

Mon, 15 May 2017 04:54:03-04:00 2017-05-15T08:54:03.0000405Z [xyz_QuartzSchedulerThread] ERROR c.v.i.c.s.s.s.QuartzMonitorImpl - Failure encountered by the Quartz Scheduler, An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Couldn't acquire next trigger: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=3.69.49
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2848) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2759) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2757) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3787) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2756) ~[quartz-2.2.1.jar:na]
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:272) ~[quartz-2.2.1.jar:na]
Caused by: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=3.69.49
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.yo.c(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.t(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.l(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.p.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.wb.b(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.qc(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.b(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.ic(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.executeUpdate(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1187) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:804) ~[com.ibm.ws.runtime.jar:na]
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.updateTriggerStateFromOtherState(StdJDBCDelegate.java:1439) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2827) ~[quartz-2.2.1.jar:na]
    ... 5 common frames omitted
Mon, 15 May 2017 04:54:03-04:00 2017-05-15T08:54:03.0000408Z [settlementScheduler_QuartzSchedulerThread] ERROR org.quartz.core.ErrorLogger - An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Couldn't acquire next trigger: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=3.69.49
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2848) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2759) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2757) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3787) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2756) ~[quartz-2.2.1.jar:na]
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:272) ~[quartz-2.2.1.jar:na]
Caused by: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=3.69.49
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.gd.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.yo.c(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.t(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.l(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.bb.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.p.a(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.t4.wb.b(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.qc(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.b(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.ic(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.db2.jcc.am.zo.executeUpdate(Unknown Source) ~[db2jcc.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1187) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:804) ~[com.ibm.ws.runtime.jar:na]
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.updateTriggerStateFromOtherState(StdJDBCDelegate.java:1439) ~[quartz-2.2.1.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2827) ~[quartz-2.2.1.jar:na]
    ... 5 common frames omitted

环境细节

DB2 Websphere(4 个带有 jndi 数据源的实例) p 系列与 ibm jdk 8 春季版 4 Quartz 版本 2.2.1(集群)

属性

datasource.db2.driverClassname=com.ibm.db2.jcc.DB2Driver org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount=5 org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.tablePrefix=T_QRTZ_ org.quartz.scheduler.skipUpdateCheck=true org.quartz.jobStore.isClustered=true org.quartz.jobStore.clusterCheckinInterval=20000 org.quartz.scheduler.instanceId=AUTO

如果有人已经遇到过这个问题并能对此有所了解,我们将不胜感激

【问题讨论】:

你在你的 WebSphere 中检查过这个吗? www-01.ibm.com/support/docview.wss?uid=swg21440972 您的 DB2 数据库中似乎遇到了死锁问题。也许这可以帮助你:ibm.com/support/knowledgecenter/SSEPGG_11.1.0/… 可能设置 org.quartz.jobStore.txIsolationLevelSerializable=true 可能会有所帮助。它是documented,因为这有助于防止某些数据库在高负载下的锁定超时和“持久”事务 【参考方案1】:

我有类似的问题。 Quartz 抱怨 死锁或超时 - 类似于您的堆栈跟踪。就我而言,异常消息有点误导,因为它实际上意味着根本没有连接到数据库。

根据quartz documentaiton,确保您满足使用JobStoreCMT 的要求:

...在尝试安排(或取消安排)作业/触发器之前,JTA 事务必须正在进行。这允许调度的“工作”成为应用程序“更大”事务的一部分......

请注意 - 只要使用 SimpleThreadPool,您的计划作业就会在 非托管线程(Websphere 之外)中运行。非托管线程无权访问服务器上下文(包括数据源、jndi 等)

考虑使用JobStoreTX 并在WorkManagers 提供的托管线程中运行作业,请参阅discussion 和my answer 与github-example。

【讨论】:

以上是关于石英调度程序无法获取触发器的主要内容,如果未能解决你的问题,请参考以下文章

如果应用程序停止,quartz 调度程序获取下一个调度程序时间

石英不触发简单触发器

如何为 cron 触发器处理石英夏令时的用户时区?

如果触发时间已过,请勿在应用启动时触发触发器。石英

Quartz Scheduler +HSQLDB 巨大的 .lobs 文件。尺寸永远增加

如何在powershell的任务调度程序中设置触发器“连接到用户会话”?