Docs/数据库/mysql/Mysql处理死锁.md
2022-10-18 16:59:37 +08:00

20 lines
No EOL
761 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 查看数据库的隔离级别
```
mysql> select @@tx_isolation;
```
### 去查看先当前库的线程情况
```
mysql> show processlist;
```
没有看到正在执行的慢SQL记录线程再去查看innodb的事务表INNODB_TRX看下里面是否有正在锁定的事务线程看看ID是否在show full processlist里面的sleep线程中如果是就证明这个sleep的线程事务一直没有commit或者rollback而是卡住了我们需要手动kill掉。
```
mysql> SELECT * FROM information_schema.INNODB_TRX;
```
如果有记录,则找到trx_mysql_thread_id这个字段对应的id, 将其kill掉。假如id=100
```
mysql->kill 100
SELECT CONCAT_WS('','kill',' ',t.trx_mysql_thread_id,';')a FROM information_schema.INNODB_TRX t;
```