Lock wait timeout exceeded; try restarting transaction_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2037 | 回复: 0   主题: Lock wait timeout exceeded; try restarting transaction        下一篇 
landy
注册用户
等级:新兵
经验:61
发帖:72
精华:0
注册:2011-12-31
状态:离线
发送短消息息给landy 加好友    发送短消息息给landy 发消息
发表于: IP:您无权察看 2014-11-13 15:21:49 | [全部帖] [楼主帖] 楼主

最近数据库总是出现Lock wait timeout exceeded; try restarting transaction的错误show innodb status内容如下(内容太长,省略一部分):=====================================

101213 17:43:27 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 2 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 7805, signal count 7795
Mutex spin waits 0, rounds 20489, OS waits 914
RW-shared spins 13512, OS waits 6748; RW-excl spins 151, OS waits 137
------------
TRANSACTIONS
------------
Trx id counter 0 130658857
Purge done for trx's n:o < 0 130278924 undo n:o < 0 0
History list length 106319
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, process no 10082, OS thread id 140279184082704
MySQL thread id 18246390, query id 82767652 localhost root
show innodb status
---TRANSACTION 0 0, not started, process no 10082, OS thread id 140279188875024
MySQL thread id 18161435, query id 82576145 localhost root
---TRANSACTION 0 130658105, not started, process no 10082, OS thread id 140279272257296
MySQL thread id 6454, query id 82752211 219.122.217.328 db_www
---TRANSACTION 0 130658182, not started, process no 10082, OS thread id 140279299680016
MySQL thread id 27, query id 82753961 219.122.217.328 db_www
---TRANSACTION 0 130658676, not started, process no 10082, OS thread id 140279271458576
MySQL thread id 5488, query id 82756872 219.122.217.328 db_www
---TRANSACTION 0 130658707, not started, process no 10082, OS thread id 140279270659856
MySQL thread id 5370, query id 82755957 219.122.217.328 db_www
---TRANSACTION 0 130657866, not started, process no 10082, OS thread id 140279272523536
MySQL thread id 5031, query id 82735738 219.122.217.328 db_www
---TRANSACTION 0 130658193, not started, process no 10082, OS thread id 140279274120976
MySQL thread id 4891, query id 82766911 219.122.217.328 db_www
---TRANSACTION 0 130658448, not started, process no 10082, OS thread id 140279275185936
MySQL thread id 4536, query id 82752223 219.122.217.328 db_www
---TRANSACTION 0 130657837, not started, process no 10082, OS thread id 140279274919696
MySQL thread id 4518, query id 82749812 219.122.217.328 db_www
---TRANSACTION 0 130658244, not started, process no 10082, OS thread id 140279275452176
MySQL thread id 4406, query id 82757507 219.122.217.328 db_www
---TRANSACTION 0 130658628, not started, process no 10082, OS thread id 140279277582096
MySQL thread id 4036, query id 82754384 219.122.217.328 db_www
---TRANSACTION 0 130658345, not started, process no 10082, OS thread id 140279278114576
MySQL thread id 3929, query id 82764686 219.122.217.328 db_www
---TRANSACTION 0 130658422, not started, process no 10082, OS thread id 140279279712016
MySQL thread id 3765, query id 82751740 219.122.217.328 db_www
---TRANSACTION 0 130658498, not started, process no 10082, OS thread id 140279281043216
MySQL thread id 3527, query id 82755901 219.122.217.328 db_www
---TRANSACTION 0 130656799, not started, process no 10082, OS thread id 140279284238096
MySQL thread id 3403, query id 82765982 219.122.217.328 db_www
---TRANSACTION 0 130658695, not started, process no 10082, OS thread id 140279283439376
MySQL thread id 3061, query id 82748769 219.122.217.328 db_www
---TRANSACTION 0 130657539, not started, process no 10082, OS thread id 140279282906896
MySQL thread id 2916, query id 82753595 219.122.217.328 db_www
---TRANSACTION 0 130658823, not started, process no 10082, OS thread id 140279284770576
MySQL thread id 2612, query id 82765695 219.122.217.328 db_www
---TRANSACTION 0 130658825, not started, process no 10082, OS thread id 140279285036816
MySQL thread id 2546, query id 82752279 219.122.217.328 db_www
---TRANSACTION 0 130658748, not started, process no 10082, OS thread id 140279286368016
MySQL thread id 2410, query id 82755756 219.122.217.328 db_www
---TRANSACTION 0 130658504, not started, process no 10082, OS thread id 140279288497936
MySQL thread id 2059, query id 82748842 219.122.217.328 db_www
---TRANSACTION 0 130657885, not started, process no 10082, OS thread id 140279287699216
MySQL thread id 1987, query id 82765729 219.122.217.328 db_www
---TRANSACTION 0 130658751, not started, process no 10082, OS thread id 140279291426576
MySQL thread id 1929, query id 82759448 219.122.217.328 db_www
---TRANSACTION 0 130658677, not started, process no 10082, OS thread id 140279289829136
MySQL thread id 1630, query id 82759396 219.122.217.328 db_www
---TRANSACTION 0 130658387, not started, process no 10082, OS thread id 140279290894096
MySQL thread id 1490, query id 82765127 219.122.217.328 db_www
---TRANSACTION 0 130658560, not started, process no 10082, OS thread id 140279291959056
MySQL thread id 1155, query id 82763775 219.122.217.328 db_www
---TRANSACTION 0 130658791, not started, process no 10082, OS thread id 140279293822736
MySQL thread id 1042, query id 82758926 219.122.217.328 db_www
---TRANSACTION 0 130658239, not started, process no 10082, OS thread id 140279294621456
MySQL thread id 677, query id 82756175 219.122.217.328 db_www
---TRANSACTION 0 130658702, not started, process no 10082, OS thread id 140279297283856
MySQL thread id 625, query id 82750399 219.122.217.328 db_www
---TRANSACTION 0 130654808, not started, process no 10082, OS thread id 140279295686416
MySQL thread id 616, query id 82751007 219.122.217.328 db_www
---TRANSACTION 0 130658736, not started, process no 10082, OS thread id 140279296218896
MySQL thread id 553, query id 82759398 219.122.217.328 db_www
---TRANSACTION 0 130658272, not started, process no 10082, OS thread id 140279298082576
MySQL thread id 238, query id 82766256 219.122.217.328 db_www
---TRANSACTION 0 130658824, not started, process no 10082, OS thread id 140279299946256
MySQL thread id 118, query id 82750479 219.122.217.328 db_www
---TRANSACTION 0 130658688, not started, process no 10082, OS thread id 140279299147536
MySQL thread id 96, query id 82763981 219.122.217.328 db_www
---TRANSACTION 0 130658620, ACTIVE 300 sec, process no 10082, OS thread id 140279271192336
MySQL thread id 5433, query id 82763616 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130658621, sees < 0 130278851
---TRANSACTION 0 130658116, ACTIVE 826 sec, process no 10082, OS thread id 140279287965456
MySQL thread id 1976, query id 82764294 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130658117, sees < 0 130278851
---TRANSACTION 0 130649990, ACTIVE 6643 sec, process no 10082, OS thread id 140279275718416
MySQL thread id 4941, query id 82763529 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130649991, sees < 0 130278851
---TRANSACTION 0 130642994, ACTIVE 11900 sec, process no 10082, OS thread id 140283684284176
MySQL thread id 7423, query id 82759158 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130642995, sees < 0 130278851
---TRANSACTION 0 130634157, ACTIVE 19292 sec, process no 10082, OS thread id 140279295952656
MySQL thread id 611, query id 82757230 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130634158, sees < 0 130278851
---TRANSACTION 0 130626742, ACTIVE 24876 sec, process no 10082, OS thread id 140279293024016
MySQL thread id 1471, query id 82757675 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130626743, sees < 0 130278851
---TRANSACTION 0 130625111, ACTIVE 26050 sec, process no 10082, OS thread id 140279294887696
2 lock struct(s), heap size 368, 1 row lock(s), undo log entries 1
MySQL thread id 667, query id 82758172 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130625112, sees < 0 130278851
---TRANSACTION 0 130624755, ACTIVE 26259 sec, process no 10082, OS thread id 140279197660944
1 lock struct(s), heap size 368, 0 row lock(s)
MySQL thread id 10932, query id 82755095 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130624756, sees < 0 130278851
---TRANSACTION 0 130528805, ACTIVE 111603 sec, process no 10082, OS thread id 140279284504336
2 lock struct(s), heap size 368, 1 row lock(s), undo log entries 1
MySQL thread id 2597, query id 82742232 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130528806, sees < 0 130278851
---TRANSACTION 0 130459300, ACTIVE 175877 sec, process no 10082, OS thread id 140279280244496
MySQL thread id 3511, query id 82762403 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130459301, sees < 0 130278851
---TRANSACTION 0 130446323, ACTIVE 185833 sec, process no 10082, OS thread id 140279292225296
5 lock struct(s), heap size 1216, 3 row lock(s), undo log entries 5
MySQL thread id 1159, query id 82762103 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130446324, sees < 0 130278851
---TRANSACTION 0 130374912, ACTIVE 249066 sec, process no 10082, OS thread id 140279297017616
1 lock struct(s), heap size 368, 0 row lock(s)
MySQL thread id 374, query id 82762282 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130374913, sees < 0 130278851
---TRANSACTION 0 130278851, ACTIVE 323303 sec, process no 10082, OS thread id 140279273588496
2 lock struct(s), heap size 368, 1 row lock(s), undo log entries 1
MySQL thread id 4872, query id 82762724 219.122.217.328 db_www
Trx read view will not see trx with id >= 0 130278852, sees < 0 130278852--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
14 read views open inside InnoDB
Main thread process no. 10082, id 140279310702352, state: sleeping
Number of rows inserted 88511, updated 175805, deleted 1, read 932701846
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.50 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT


============================哪位高手可以帮忙看一下是什么原因导致这个错误呢?另外query id 82758172具体是什么语句呢?

解决方案 »

似乎是某些SQL操作锁定时间过长导致事务没法在有效时间内提交。

超时以后,未提交的事务会自动回滚。

1 看你err log里面的内容

2 优化你慢查询日志中的内容

锁定超时,回滚的一个问题.

可以加大 innodb_lock_wait_timeout 参数试下

找到执行的是什么SQL语句,优化一下试试

出现Lock wait timeout exceeded; try restarting transaction的错误都是对innodb的表进行update操作时出现,比如执行update user set rank = 1 where uid =1234;时就经常出现这个错误。

过了N个小时后再执行这条语句还是会报这个错,难道是还没有回滚吗?另外,为什么我show innodb status没有LATEST FOREIGN KEY ERROR 和 LATEST DETECTED DEADLOCK 部分呢?

我err log里都是INNODB MONITOR的输出

慢查询日志经常出现的语句类似update user set rank = 1 where uid =1234;

uid 上建立索引没有,如没有,加上

检查下对表user 的操作语句,有没lock table后没有释放,或者set autocommit=0后没有设回1一般是行锁造成的。

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论