师傅领进门,修行靠个人。

关于Lock wait timeout exceeded; try restarting transaction

上一篇 / 下一篇  2013-03-01 13:38:50 / 个人分类:数据库


问题描述:在mysql的gameshop数据库上操作删除语句,数据库一直在执行,响应完后,报Lock wait timeout exceeded;try restarting transaction; 执行delete语句删除失败。

原因:有会话执行过DML操作,然后没commit提交,再执行删除操作,就锁了。
__________________________________________________________________________

Lock wait timeout exceeded; try restarting transaction一些信息

1、锁等待超时。是当前事务在等待其它事务释放锁资源造成的。可以找出锁资源竞争的表和语句,优化你的SQL,创建索引等,如果还是不行,可以适当减少并发线程数。

2、你的事务在等待给某个表加锁时超时了,估计是表正被另的进程锁住一直没有释放。
可以用 SHOW INNODB STATUS/G; 看一下锁的情况。

3、搜索解决 之道
在管理 节点的[ndbd default]
区加:
TransactionDeadLockDetectionTimeOut=10000(设置 为10秒)默认是1200(1.2秒)

4、

InnoDB会自动的检测死锁进行回滚,或者终止死锁的情况。


引用
InnoDB automatically detects transaction deadlocks and rolls back a transaction or transactions to break the deadlock. InnoDB tries to pick small transactions to roll back, where the size of a transaction is determined by the number of rows inserted, updated, or deleted.


如果参数innodb_table_locks=1并且autocommit=0时,InnoDB会留意表的死锁,和MySQL层面的行级锁。另外,InnoDB不会检测MySQL的Lock Tables命令和其他存储引擎死锁。
你应该设置innodb_lock_wait_timeout来解决这种情况。
innodb_lock_wait_timeout是Innodb放弃行级锁的超时时间。


TAG:

 

评分:0

我来说两句

Open Toolbar