2021-04-14 mysql-排查故障常用命令 整理的常用mysql排查命令 mysql 8.0 123456789101112131415161718192021222324252627282930## 当前运行的所有事务mysql> select * from information_schema.innodb_trx\G;## 查看锁使用情况mysql> show status like 'innodb_row_lock_%';+-------------------------------+--------+| Variable_name | Value |+-------------------------------+--------+| Innodb_row_lock_current_waits | 1 || Innodb_row_lock_time | 479764 || Innodb_row_lock_time_avg | 39980 || Innodb_row_lock_time_max | 51021 || Innodb_row_lock_waits | 12 |+-------------------------------+--------+5 rows in set (0.00 sec)解释如下:Innodb_row_lock_current_waits : 当前等待锁的数量Innodb_row_lock_time : 系统启动到现在,锁定的总时间长度Innodb_row_lock_time_avg : 每次平均锁定的时间Innodb_row_lock_time_max : 最长一次锁定时间Innodb_row_lock_waits : 系统启动到现在总共锁定的次数 # 查询是否锁表mysql> show OPEN TABLES where In_use > 0;+----------+-------+--------+-------------+| Database | Table | In_use | Name_locked |+----------+-------+--------+-------------+| test | tx1 | 1 | 0 |+----------+-------+--------+-------------+1 row in set (0.00 sec) Newer openstack-裸金属ironic整理-6 Older go-map赋值前要先初始化:assignment to entry in nil map