mysql deadlock found when trying to get lock 问题排查
2017-04-01 13:02
543 查看
mysql deadlock found when trying to get lock 问题排查
1 获 取锁等待情况
可以通过检查 table_locks_waited和table_locks_immediate状态变量来分析系统上的表锁定争夺:mysql> show status like 'Table%'; +----------------------------+----------+ | Variable_name | Value | +----------------------------+----------+ | Table_locks_immediate | 105 | | Table_locks_waited | 3 | +----------------------------+----------+ 2 rows in set (0.00 sec)
2 可以通过检查 Innodb_row_lock状态变量来分析系统上的行锁的争夺情况:
mysql> show status like 'innodb_row_lock%'; +----------------------------------------+----------+ | Variable_name | Value | +----------------------------------------+----------+ | Innodb_row_lock_current_waits | 0 | | Innodb_row_lock_time | 2001 | | Innodb_row_lock_time_avg | 667 | | Innodb_row_lock_time_max | 845 | | Innodb_row_lock_waits | 3 | +----------------------------------------+----------+ 5 rows in set (0.00 sec)
3 设置监视器
另外,针对Innodb类型的表,如果 需要察看当前的锁等待情况,可以设置InnoDB Monitors,然后通过Show innodb status察看,设置的方式是:CREATE TABLE innodb_monitor(a INT) ENGINE=INNODB;
监视器可以通过发出下列语句来被停止:
DROP TABLE innodb_monitor;
设置监视器后,在
show innodb status(高版本使用:
show engine innodb status)的显示内容中,会有详细的当前锁等待的信息,包括表名、锁类型、锁定记录的情况等等,便于进行进一步的分析和问题的确定。打开监视器以后,默 认情况下每15秒会向日志中记录监控的内容,如果长时间打开会导致.err文件变得非常的巨大,所以我们在确认问题原因之后,要记得删除监控表以关闭监视 器。或者通过使用--console选项来启动服务器以关闭写日志文件。
4 查看自己占用的连接
如果是root帐号,你能看到所有用户的当前连接。如果是其它普通帐号,只能看到自己占用的连接。show processlist;只 列出前100条,如果想全列出请使用
show full processlist;
mysql> show processlist;
相关文章推荐
- mysql报错:Deadlock found when trying to get lock; try restarting transaction的解决方法
- 关于mysql中select * for update锁表与Deadlock found when trying to get lock; try restarting transaction
- mysql 报ERROR:Deadlock found when trying to get lock; try restarting transaction
- mysql 死锁 Deadlock found when trying to get lock; t
- Deadlock found when trying to get lock; try restarting transaction
- mysql数据库死锁:Deadlock found when trying to get lock; try restarting transaction
- deadlock found when trying to get lock ;try restarting transaction
- mysql innodb 事务操作的表锁及行锁-Deadlock found when trying to get lock; try restarting transaction的优化
- Deadlock found when trying to get lock; try restarting transaction
- SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting
- Deadlock found when trying to get lock; try restarting transaction
- ORA-04020: deadlock detected while trying to lock object 报错问题解决步骤
- Oracle 9i 升级中的bug-- Sys.Cdc_alter_ctable_before ORA-04020 deadlock detected while trying to lock object
- weblogic unable to get file lock问题
- weblogic unable to get file lock问题
- weblogic unable to get file lock问题
- weblogic unable to get file lock问题
- How to resolve mysql problem when you get code 2003(10061) and 1130
- Oracle 9i 升级中的bug-- Sys.Cdc_alter_ctable_before ORA-04020 deadlock detected while trying to lock object
- MySQL connector C++在Linux下编译undefined reference to 'get_driver_instance'问题