首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >一致的疑难解答"SQLException:锁定等待超时“

一致的疑难解答"SQLException:锁定等待超时“
EN

Stack Overflow用户
提问于 2009-05-19 09:31:38
回答 1查看 12K关注 0票数 9

我有一个运行Quartz 1.6.1w/持久性作业存储的应用程序,其中MySQL 5.1作为DB。这个应用程序过去可以在Tomcat6中启动。在某个时候,它开始在每次引导上抛出以下异常:

代码语言:javascript
运行
复制
- 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 /Hibernate,使用C3P0作为数据源连接池。此异常总是在JPA完成更新我的架构后直接抛出。

首先,我升级到Quartz 1.6.5,异常消失了,但是应用程序似乎被冻结了。日志中的最后一件事--过去的例外情况--是:

代码语言:javascript
运行
复制
...hbm2ddl stuff...
2969 [Thread-1] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete
- Handling 6 trigger(s) that missed their scheduled fire-time.

之后什么都没有出现,而and应用程序也没有为请求提供服务;它们只是无限期地挂起。

当我在异常后运行具有显示INNODB状态的mysql命令行客户端时,它始终显示两个可疑的事务:

代码语言:javascript
运行
复制
----------
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客户端抛出了一个“超过锁定等待超时”错误。此时,我停止了我的(仍然挂起的)应用程序,然后能够删除qrtz_triggers表的所有行。一旦完成,我就能够成功地启动我的应用程序。

看来我需要记录一个新的Quartz错误,但我想给他们提供更多的信息,什么是真正的纠缠在这里。因此,根据最初的问题,我如何解决这些类型的问题?

EN

回答 1

Stack Overflow用户

发布于 2012-03-29 20:37:02

你试过跑步吗

show processlist

show full processlist

从mysql命令行?这些通常会显示锁定查询的完整sql。它还将显示进程运行该查询的时间。它可以帮助你更接近答案。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/881810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档