集群下acquireNextTrigger报死锁异常

piaoling19 发布于 2016/04/03 10:05
阅读 1K+
收藏 0
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Deadlock found when trying to get lock; try restarting transaction
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2860) ~[quartz-2.2.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2759) ~[quartz-2.2.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2757) ~[quartz-2.2.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3799) ~[quartz-2.2.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2756) ~[quartz-2.2.2.jar:na]
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:272) ~[quartz-2.2.2.jar:na]
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_55]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_55]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_55]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_55]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:408) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.Util.getInstance(Util.java:383) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4208) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2597) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2758) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2826) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2334) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2262) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2246) ~[mysql-connector-java-5.1.32.jar:na]
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) ~[c3p0-0.9.1.1.jar:0.9.1.1]
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.updateTriggerStateFromOtherState(StdJDBCDelegate.java:1439) ~[quartz-2.2.2.jar:na]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2839) ~[quartz-2.2.2.jar:na]
    ... 5 common frames omitted

加载中
0
为梦而来
为梦而来

不知道你的问题解决了没,我也是纠结了两天了,和同事一同商量找到了最终的问题解决方案,分享给你一下,

quartz文档提到,如果在集群环境下,最好将配置项org.quartz.jobStore.txIsolationLevelSerializable设置为true

这个选项在mysql下会非常容易出现死锁问题。

quartz需要提升隔离级别来保障自己的运作,而不同类型的数据对隔离的实现不同,所以quartz提供一个设置序列化的隔离级别由于mysql默认的是可重复读,比提交读高了一个级别,所以已经可以满足quartz集群的正常运行。

所以将quartz.properties  org.quartz.jobStore.txIsolationLevelSerializable = false 即可解决此问题。

返回顶部
顶部