我有一個運行Quartz 1.6.1 w/persistent job store的應用程序,其中MySQL 5.1作爲數據庫。這個應用程序用於在Tomcat6中啓動。在某些時候,它開始在每次啓動時拋出以下異常:故障排除一致的「SQLException:超出鎖定等待超時」
- MisfireHandler: Error handling misfires: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction
org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction [See nested exception: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction]
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:112)
at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:112)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3075)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:3838)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:3858)
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:92)
... 4 more
我應該提及此應用程序還利用JPA W/Hibernate的使用C3P0的數據源連接池。在JPA完成我的模式更新後,此異常始終直接拋出。
首先,我升級到了Quartz 1.6.5,異常消失了,但應用程序似乎凍結了。在異常曾經是 - - 在日誌的最後一件事是:
...hbm2ddl stuff...
2969 [Thread-1] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete
- Handling 6 trigger(s) that missed their scheduled fire-time.
用什麼來後,和web應用程序不會請求提供服務;他們只是無限期地掛起。
當我運行mysql的命令行客戶端與SHOW INNODB STATUS異常之後,它始終顯示兩個可疑交易:
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 49, signal count 49
Mutex spin waits 0, rounds 2100, OS waits 0
RW-shared spins 115, OS waits 49; RW-excl spins 0, OS waits 0
------------
TRANSACTIONS
------------
Trx id counter 0 165688
Purge done for trx's n:o < 0 165685 undo n:o < 0 0
History list length 12
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, OS thread id 5012
MySQL thread id 8, query id 1798 localhost 127.0.0.1 root
SHOW INNODB STATUS
---TRANSACTION 0 165687, ACTIVE 300 sec, OS thread id 3772
2 lock struct(s), heap size 320, 1 row lock(s)
MySQL thread id 30, query id 1795 localhost 127.0.0.1 my_app
---TRANSACTION 0 165685, ACTIVE 360 sec, OS thread id 5460
2 lock struct(s), heap size 320, 1 row lock(s), undo log entries 1
MySQL thread id 34, query id 1680 localhost 127.0.0.1 my_app
我正在尋找指導如何進一步調查這個問題。也許如果我能以某種方式識別這兩個交易的所有者,或者他們鎖定了哪些資源?
更新:我刪除的所有行qrtz_simple_triggers表沒有問題。然後,我試圖在qrtz_triggers表上做同樣的事情,我的MySQL客戶端拋出了「超出鎖定等待超時」錯誤。此時,我停止了我的(仍懸掛的)應用程序,然後能夠刪除表中所有行。一旦完成,我能夠成功啓動我的應用程序。
看來我需要記錄一個新的Quartz錯誤,但我希望能夠給他們更多關於這裏實際發生的事情的信息。因此,根據原始問題,我該如何解決這些類型的問題?