当前位置:网站首页>mysql deadlock
mysql deadlock
2022-07-30 21:05:00 【Carrot rabbit】
1. View transactions in progress
SELECT * FROM information_schema.INNODB_TRX;
mysql> SELECT * FROM information_schema.INNODB_TRX \G;**************************** 1. row **************************trx_id: 331123705trx_state: RUNNINGtrx_started: 2022-07-19 13:47:12trx_requested_lock_id: NULLtrx_wait_started: NULLtrx_weight: 0trx_mysql_thread_id: 11355trx_query: NULLtrx_operation_state: NULLtrx_tables_in_use: 0trx_tables_locked: 0trx_lock_structs: 0trx_lock_memory_bytes: 360trx_rows_locked: 0trx_rows_modified: 0trx_concurrency_tickets: 0trx_isolation_level: REPEATABLE READtrx_unique_checks: 1trx_foreign_key_checks: 1trx_last_foreign_key_error: NULLtrx_adaptive_hash_latched: 0trx_adaptive_hash_timeout: 10000trx_is_read_only: 0trx_autocommit_non_locking: 0**************************** 2. row **************************trx_id: 331123681trx_state: RUNNINGtrx_started: 2022-07-19 13:47:09trx_requested_lock_id: NULLtrx_wait_started: NULLtrx_weight: 397trx_mysql_thread_id: 11409trx_query: update sys_role_user ruinner join sys_role r on ru.client_role_id = r.client_role_idinner join sys_user_center uc on ru.client_user_id = uc.idset ru.role_id = r.id, ru.open_id = uc.open_idwhere (ru.role_id is null or ru.open_id is null) and ru.update_time >= '2022-07-19 13:47:09'and ru.client_id = 'webApp' and ru.`enable` = '1000102'trx_operation_state: fetching rowstrx_tables_in_use: 3trx_tables_locked: 3trx_lock_structs: 397trx_lock_memory_bytes: 63016trx_rows_locked: 109781trx_rows_modified: 0trx_concurrency_tickets: 0trx_isolation_level: REPEATABLE READtrx_unique_checks: 1trx_foreign_key_checks: 1trx_last_foreign_key_error: NULLtrx_adaptive_hash_latched: 0trx_adaptive_hash_timeout: 9974trx_is_read_only: 0trx_autocommit_non_locking: 02 rows in set (0.00 sec)
If it is found that trx_state
is LOCK_WAIT
, a deadlock occurs, you can use trx_mysql_thread_id
mysql thread, and pass kill thread
kill thread
2 . View locked transactions
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
3. View transactions waiting for locks
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
4. Check whether the table is locked
SHOW OPEN TABLES where In_use > 0;
5. Resolving deadlocks
Remove deadlock
If you need to remove the deadlock, there is one of the simplest and rude ways, that is, after finding the process id, kill it directly.
View currently ongoing processes
show processlist
// Also available
SELECT * FROM information_schema.INNODB_TRX;
The process id found by these two commands is the same.
kill the process corresponding to the process
kill id
Verify (after killing to see if there is still a lock)
SHOW OPEN TABLES where In_use > 0;
边栏推荐
- [The Beauty of Software Engineering - Column Notes] 31 | Is software testing responsible for product quality?
- 【信息安全技术】RSA算法的研究及不同优化策略的比较
- MySQL的Replace用法详解
- mysql死锁
- 【软件工程之美 - 专栏笔记】31 | 软件测试要为产品质量负责吗?
- 【深度学习】对迁移学习中域适应的理解和3种技术的介绍
- ENS 表情包域名火了!是炒作还是机遇?
- Why do so many people who teach themselves software testing give up later...
- 用于视频压缩伪影消除的深度卡尔曼滤波网络
- opencv,numpy,tensor格式转换
猜你喜欢
随机推荐
MySQL的Replace用法详解
MYSQL 唯一约束
How to make a deb package
触摸屏状态机
7、MySQL Workbench 导出导入数据库
啊?现在初级测试招聘都要求会自动化了?
5分钟搞懂MySQL - 行转列
《快速掌握QML》第六章 动画
Network layer protocol------IP protocol
想要写出好的测试用例,先要学会测试设计
Quick Master QML Chapter 6 Animation
Oblique document scanning and character recognition (opencv, coordinate transformation analysis)
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上
一个网络两种用途!南开&哈工程提出TINet,通过细化纹理和边缘,在显著性目标检测和伪装目标检测上实现双SOTA!...
Mysql 回表
DPW-SDNet: Dual Pixel-Wavelet Domain Deep CNNsfor Soft Decoding of JPEG-Compressed Images
【软件工程之美 - 专栏笔记】31 | 软件测试要为产品质量负责吗?
Flex布局详解
chrome扩展:如何使对话框位于当前窗口的右侧?
kubernetes