当前位置:网站首页>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;
边栏推荐
- DPW-SDNet: Dual Pixel-Wavelet Domain Deep CNNsfor Soft Decoding of JPEG-Compressed Images
- Swift RegexBuilder Vs. Raku Grammar
- Running the evict task with compensationTime
- KingbaseES TOAST存储方式
- Oracle ADG状态查看与相关视图
- [Machine Learning] The Beauty of Mathematics Behind Gradient Descent
- MYSQL JDBC图书管理系统
- ENS 表情包域名火了!是炒作还是机遇?
- KingbaseESV8R6 snapshot too old的配置和测试
- 转义字符笔记记录
猜你喜欢
随机推荐
【回归预测-CNN预测】基于卷积神经网络CNN实现数据回归预测附matlab代码
关于MySQL主从复制的数据同步延迟问题
对List集合中每个对象元素按时间顺序排序
【信息安全技术】RSA算法的研究及不同优化策略的比较
Deep Kalman Filter Network for Video Compression Artifact Removal
Flex布局详解
Image Restoration by Estimating Frequency Distribution of Local Patches
C语言中指针没那么难~ (1)【文章结尾有资料】
用于命名实体识别的模块化交互网络
数据指标口径不统一、重复开发?亿信ABI指标管理平台帮你解决
第04章 逻辑架构【1.MySQL架构篇】【MySQL高级】
深入浅出边缘云 | 3. 资源配置
Mysql索引特性(重要)
js堆和栈
Structured Streaming报错记录:Overloaded method foreachBatch with alternatives
chrome extension: how to make the dialog be on the right side of the current window?
MYSQL 唯一约束
LeetCode·23.合并K个升序链表·递归·迭代
kubernetes
Quick Master QML Chapter 6 Animation