当前位置:网站首页>mysql 查看死锁
mysql 查看死锁
2022-08-02 02:21:00 【iiaythi】
mysql 查看死锁
查看正在进行中的事务
MySQL [test]> SELECT * FROM information_schema.INNODB_TRX\G;
*************************** 1. row ***************************
trx_id: 3377
trx_state: RUNNING
trx_started: 2022-08-01 09:03:55
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 3
trx_mysql_thread_id: 21
trx_query: NULL
trx_operation_state: NULL
trx_tables_in_use: 0
trx_tables_locked: 1
trx_lock_structs: 2
trx_lock_memory_bytes: 1128
trx_rows_locked: 1
trx_rows_modified: 1
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 0
trx_is_read_only: 0
trx_autocommit_non_locking: 0
trx_schedule_weight: NULL
*************************** 2. row ***************************
trx_id: 3376
trx_state: LOCK WAIT
trx_started: 2022-08-01 09:03:48
trx_requested_lock_id: 139908142630480:3:4:3:139908022887848
trx_wait_started: 2022-08-01 09:04:02
trx_weight: 4
trx_mysql_thread_id: 20
trx_query: update t_user set age=12 where id=2
trx_operation_state: starting index read
trx_tables_in_use: 1
trx_tables_locked: 1
trx_lock_structs: 3
trx_lock_memory_bytes: 1128
trx_rows_locked: 2
trx_rows_modified: 1
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 0
trx_is_read_only: 0
trx_autocommit_non_locking: 0
trx_schedule_weight: 1
2 rows in set (0.00 sec)
查询是否锁表
MySQL [test]> SHOW OPEN TABLES where In_use > 0\G;
*************************** 1. row ***************************
Database: test
Table: t_user
In_use: 1
Name_locked: 0
1 row in set (0.00 sec)
查看最近死锁的日志
MySQL [test]> show engine innodb status\G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
------------
TRANSACTIONS
------------
Trx id counter 3378
Purge done for trx's n:o < 3376 undo n:o < 0 state: running but idle
History list length 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421383119340328, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
2 lock struct(s), heap size 1128, 1 row lock(s), undo log entries 1
MySQL thread id 21, OS thread handle 139907958769408, query id 467 192.168.226.1 root
---TRANSACTION 3376, ACTIVE 182 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 1128, 4 row lock(s), undo log entries 1
MySQL thread id 20, OS thread handle 139907959826176, query id 479 192.168.226.1 root updating
update t_user set age=12 where id=2
------- TRX HAS BEEN WAITING 17 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 3 page no 4 n bits 72 index PRIMARY of table `test`.`t_user` trx id 3376 lock_mode X locks rec but not gap waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 8; hex 8000000000000002; asc ;;
1: len 6; hex 000000000d31; asc 1;;
2: len 7; hex 010000011906f8; asc ;;
3: len 2; hex 6262; asc bb;;
4: len 4; hex 8000000e; asc ;;
可以发现 线程 20和21 被锁住了
看正在执行的sql
MySQL [test]> show processlist;
+----+-----------------+---------------------+------+---------+--------+------------------------+-------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+---------------------+------+---------+--------+------------------------+-------------------------------------+
| 5 | event_scheduler | localhost | NULL | Daemon | 231380 | Waiting on empty queue | NULL |
| 17 | root | 172.22.0.1:34568 | test | Query | 0 | init | show processlist |
| 18 | root | 192.168.226.1:50436 | test | Sleep | 1689 | | NULL |
| 19 | root | 192.168.226.1:50437 | test | Sleep | 1690 | | NULL |
| 20 | root | 192.168.226.1:64269 | test | Query | 9 | updating | update t_user set age=12 where id=2 |
| 21 | root | 192.168.226.1:64292 | test | Sleep | 265 | | NULL |
kill 线程
MySQL [test]> kill 21;
Query OK, 0 rows affected (0.00 sec)
边栏推荐
- Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记
- Check if IP or port is blocked
- Nanoprobes免疫测定丨FluoroNanogold试剂免疫染色方案
- 2022-08-01 安装mysql监控工具phhMyAdmin
- 60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
- 列表常用方法
- Nanoprobes丨1-mercapto-(triethylene glycol) methyl ether functionalized gold nanoparticles
- AWR分析报告问题求助:SQL如何可以从哪几个方面优化?
- 永磁同步电机36问(二)——机械量与电物理量如何转化?
- Effects of Scraping and Aggregation
猜你喜欢

Nanoprobes纳米探针丨Nanogold偶联物的特点和应用

Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings

Nanoprobes丨1-mercapto-(triethylene glycol) methyl ether functionalized gold nanoparticles
![[LeetCode Daily Question]——654. The largest binary tree](/img/05/0af1c6dc0085e253c0758c8da63e52.png)
[LeetCode Daily Question]——654. The largest binary tree

工程师如何对待开源

GTK RGB图像绘制

Unable to log in to the Westward Journey
![[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree](/img/b9/35813ae2972375fa728e3c11fab5d3.png)
[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree

Redis 底层的数据结构

How engineers treat open source
随机推荐
永磁同步电机36问(二)——机械量与电物理量如何转化?
NIO‘s Sword(牛客多校赛)
BI-SQL丨WHILE
列表常用方法
Coding Experience Talk
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
libcurl访问url保存为文件的简单示例
oracle查询扫描全表和走索引
Redis for distributed applications in Golang
记一个gorm初始化的坑
【LeetCode Daily Question】——704. Binary Search
2023年起,这些地区软考成绩低于45分也能拿证
2022-08-01 Install mysql monitoring tool phhMyAdmin
通用客户端架构
【LeetCode每日一题】——654.最大二叉树
机器人领域期刊会议汇总
29. 删除链表中重复的节点
LeetCode brushing diary: 53, the largest sub-array and
EFCore 反向工程
"NetEase Internship" Weekly Diary (2)