解决 之道 问题描述:在mysql的gameshop数据库上操作删除语句,数据库一直在执行,响应完后,报Lock wait timeout exceeded;try restarting transaction; 执行delete语句删除失败。 原因:有会话执行过DML操作,然后没commit提交,再执行删除操作,就锁了。 __________________________________________________________________________ Lock wait timeout exceeded; try restarting transaction一些信息 1、锁等待超时。是当前事务在等待其它事务释放锁资源造成的。可以找出锁资源竞争的表和语句,优化你的SQL,创建索引等,如果还是不行,可以适当减少并发线程数。 2、你的事务在等待给某个表加锁时超时了,估计是表正被另的进程锁住一直没有释放。 3、搜索解决 之道 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.
|
|