当前位置:网站首页>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)
边栏推荐
- How to adjust the cross cursor too small, CAD dream drawing calculation skills
- AOF rewrite
- 用位运算为你的程序加速
- leetcode / anagram in string - some permutation of s1 string is a substring of s2
- MySQL8 download, start, configure, verify
- Moonbeam and Project integration of the Galaxy, bring brand-new user experience for the community
- cocos中使用async await异步加载资源
- [Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games
- The underlying data structure of Redis
- LeetCode brush diary: LCP 03. Machine's adventure
猜你喜欢
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
Nanoprobes免疫测定丨FluoroNanogold试剂免疫染色方案
Check if IP or port is blocked
记一个gorm初始化的坑
【LeetCode Daily Question】——704. Binary Search
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
The state status is displayed incorrectly after the openGauss switch
Analysis of volatile principle
The failure to create a role in Dahua Westward Journey has been solved
2023年起,这些地区软考成绩低于45分也能拿证
随机推荐
Win Go development kit installation configuration, GoLand configuration
Electronic Manufacturing Warehouse Barcode Management System Solution
2022-08-01 Reflection
GTK RGB图像绘制
Analysis of volatile principle
swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
【web】理解 Cookie 和 Session 机制
"NetEase Internship" Weekly Diary (2)
Check if IP or port is blocked
【Unity入门计划】2D Game Kit:初步了解2D游戏组成
CASE2023
Handwriting a blogging platform ~ the first day
Redis 底层的数据结构
一次SQL优化,数据库查询速度提升 60 倍
2022-08-01 安装mysql监控工具phhMyAdmin
MySQL optimization strategy
AWR分析报告问题求助:SQL如何可以从哪几个方面优化?
Ask God to answer, how should this kind of sql be written?
2022 Henan Youth Training League Game (3)
力扣(LeetCode)213. 打家劫舍 II(2022.08.01)