quartz scheduler无法获取触发器

时间:2017-05-18 07:12:41

标签: spring jdbc db2 websphere quartz-scheduler

我正在与客户合作并解决不时触发工作的问题。

以下是错误的示例,这种情况经常发生,并且还会导致无法触发作业。

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(使用jndi数据源的4个实例)
  • p系列与ibm jdk 8
  • Spring version 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 =真 org.quartz.jobStore.isClustered =真 org.quartz.jobStore.clusterCheckinInterval = 20000 org.quartz.scheduler.instanceId = AUTO

如果有人已经面对这个问题并且可以对此有所了解,那将会很感激

1 个答案:

答案 0 :(得分:0)

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

  • 根据quartz documentaiton确保您符合使用JobStoreCMT所需的条件:

      

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

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

  • 考虑使用JobStoreTX并在WorkManagers提供的托管线程中运行作业,请discussionmy answer github-example