惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 哈喽哈喽111111

RockyLinux SSH 跳板转发 3389(Windows 远程桌面)完整方案 MySQL使用自带的logrotate配置日志轮转 yum方式安装redis7 nacos新加用户操作 网络运营商禁止端口信息 Linux开机启动rc.local不生效的一般解决方案 Nginx流量拷贝ngx_http_mirror_module模块使用方法详解 Adobe 修改 hosts 文件 axios 投毒与好莱坞式骗术 Linux系统在使用systemctl启动服务的失败,报错如下:Error No space left on device git submodule 的增、查、改、删 Rocky Linux 安装 Google Chrome 浏览器 “头号玩家”—— 美国技术霸权下的全球虚拟货币资产收割行动深层解析 你是第几级 AI 编程 MySQL中通过关联update将一张表的一个字段更新到另外一张表中 Linux 的 Port Knocking 端口碰撞(端口敲门) jar文件解压缩操作 设置Windows服务器远程桌面能使用多个桌面 20251024- 使用shell脚本分库定时备份MySQL数据 禁用sentinel 在 Linux 中安装和配置 NTP 服务器和 NTP 客户端 springboot配置文件关系及加载顺序 用自带的Nginx为gitlab做白名单 Rocky9和Ubuntu使用pip安装python的库mysqlclient失败解决方式 在Spring Boot Admin中根据Nacos的命名空间来区分和管理不同的环境
MySQL解除死锁
哈喽哈喽111111 · 2025-12-09 · via 博客园 - 哈喽哈喽111111
报错日志:Lock wait timeout exceeded; try restarting transaction

【治标方法】事务信息查询

通过脚本:SELECT * FROM information schema.innodb_trx
查询未提交事务,査到没有提交的只读事务(trx_state="LOCKWAIT"),
找到对应线程,执行kill命令,其中线程id为表中的trx_mysqlthread_id字段。


mysql> SELECT * FROM information_schema.innodb_trx;
+-----------------+-----------+---------------------+-------------------------------------------+---------------------+------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+---------------------+-----------------+
| trx_id          | trx_state | trx_started         | trx_requested_lock_id                     | trx_wait_started    | trx_weight | trx_mysql_thread_id | trx_query                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | trx_operation_state | trx_tables_in_use | trx_tables_locked | trx_lock_structs | trx_lock_memory_bytes | trx_rows_locked | trx_rows_modified | trx_concurrency_tickets | trx_isolation_level | trx_unique_checks | trx_foreign_key_checks | trx_last_foreign_key_error | trx_adaptive_hash_latched | trx_adaptive_hash_timeout | trx_is_read_only | trx_autocommit_non_locking | trx_schedule_weight | trx_waited_time |
+-----------------+-----------+---------------------+-------------------------------------------+---------------------+------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+---------------------+-----------------+
|        83488431 | LOCK WAIT | 2025-12-02 15:20:33 | 140673625892520:1228:4:10:140667004024864 | 2025-12-02 15:20:33 |          2 |            31233061 | UPDATE cs_xx_kpzd SET create_by = 'jdd_admin_user', create_time = '2025-11-21 11:14:55', update_by = 'jdd_admin_user', update_time = '2025-12-02 15:20:33.777', sys_org_code = 'A03A01A01A23A01', tenant_id = 1001, company_id = '1982703852667277314', zddm = '91411224MA460BGYXG', zdmc = '卢氏县清河加油站', zdlx = 'sd', fwqid = '', kpms = 'fxtd', tdyw = '01', fplxdm = '01,02', nsrdm = '91411224MA460BGYXG', nsrsbh = '91411224MA460BGYXG', nsrmc = '卢氏县清河加油站', xfyh = '河南卢氏农村商业银行股份有限公司潘河支行', xfyhzh = '09408001100000041', xfdz = '卢氏县潘河乡清河村S250省道北方矿业对面', xfdh = '13939887301', dzswjzh = '13939887301', dzswjmm = 'Aa111111', dljs = '1', sjh = '13290813447', dljsmm = '1Y/Zm6qktq+cWCrav4t/sw==', dlsj = '2025-12-02 15:20:33.776', zxzt = '在线', dzswjpzid = '1991706544500641794', jybs = '0' WHERE cs_xx_kpzd.tenant_id = 1001 AND id = '1991706863229997057' | starting index read |                 1 |                 1 |                2 |                  1128 |               1 |                 0 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 |                   1 |              21 |
|        83360270 | RUNNING   | 2025-12-02 11:59:43 | NULL                                      | NULL                |          3 |            31250291 | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | NULL                |                 0 |                 1 |                2 |                  1128 |               1 |                 1 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 | NULL                |               0 |
| 422148602666008 | RUNNING   | 2025-12-02 10:52:40 | NULL                                      | NULL                |          0 |            31250495 | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | NULL                |                 0 |                 0 |                0 |                  1128 |               0 |                 0 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 | NULL                |               0 |
| 422148602605624 | RUNNING   | 2025-12-02 09:44:32 | NULL                                      | NULL                |          0 |            31229753 | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | NULL                |                 0 |                 0 |                0 |                  1128 |               0 |                 0 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 | NULL                |               0 |
| 422148602632552 | RUNNING   | 2025-12-02 11:59:10 | NULL                                      | NULL                |          0 |            30913938 | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | NULL                |                 0 |                 0 |                0 |                  1128 |               0 |                 0 |                       0 | REPEATABLE READ     |                 1 |                      1 | NULL                       |                         0 |                         0 |                0 |                          0 | NULL                |               0 |
+-----------------+-----------+---------------------+-------------------------------------------+---------------------+------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+---------------------+-----------------+
5 rows in set (0.07 sec)

kill trx_mysqlthread_id  =》kill 31233061;


【治标方法】如果杀掉线程依然不能解决,可以查找执行线程耗时比较久的任务,kill掉

SELECT * from information_schema.`PROCESSLIST` WHERE Time > 1000 AND USER = 'xxx' ORDER BY TIME desc;

kill 线程ID