当前位置:网站首页>mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
2022-08-11 01:56:00 【CSDN问答】
运行结果及报错内容
程序中报错 Caused by: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
数据库死锁日志:
SHOW ENGINE INNODB STATUS\G
------------------------LATEST DETECTED DEADLOCK------------------------2022-08-04 05:01:26 0x7feefb651700*** (1) TRANSACTION:TRANSACTION 106317343, ACTIVE 0 sec starting index readmysql tables in use 1, locked 1LOCK WAIT 4 lock struct(s), heap size 1136, 2 row lock(s)MySQL thread id 26764, OS thread handle 140664341653248, query id 152316867 127.0.0.1 meita-zhenjian updatingUPDATE table1 SET toreadflag = 1 WHERE id = 758489*** (1) WAITING FOR THIS LOCK TO BE GRANTED:RECORD LOCKS space id 534 page no 117 n bits 160 index PRIMARY of table `db1`.`table1` /* Partition `p90` */ trx id 106317343 lock_mode X locks rec but not gap waitingRecord lock, heap no 94 PHYSICAL RECORD: n_fields 31; compact format; info bits 0*** (2) TRANSACTION:TRANSACTION 106317342, ACTIVE 0 sec starting index readmysql tables in use 1, locked 14 lock struct(s), heap size 1136, 2 row lock(s)MySQL thread id 26758, OS thread handle 140664396650240, query id 152316868 127.0.0.1 meita-zhenjian updatingUPDATE table1 SET toreadflag = 1 WHERE id = 893363*** (2) HOLDS THE LOCK(S):RECORD LOCKS space id 534 page no 117 n bits 160 index PRIMARY of table `db1`.`table1` /* Partition `p90` */ trx id 106317342 lock_mode X locks rec but not gapRecord lock, heap no 94 PHYSICAL RECORD: n_fields 31; compact format; info bits 0*** (2) WAITING FOR THIS LOCK TO BE GRANTED:RECORD LOCKS space id 508 page no 199 n bits 136 index PRIMARY of table `db1`.`table1` /* Partition `p64` */ trx id 106317342 lock_mode X locks rec but not gap waitingRecord lock, heap no 70 PHYSICAL RECORD: n_fields 31; compact format; info bits 0*** WE ROLL BACK TRANSACTION (2)
我的解答思路和尝试过的方法
之前感觉是表数据量太大, 多线程不停的update 数据,
索引更新时短暂的 锁表导致 此报错的出现,
后 将表分区, 但仍然出现这个报错此表 下 id 为 自增主键, 共有 3个索引
1个主键 索引
2个普通索引
update 语句中 where 条件为 id 是主键索引
set 条件中 无索引
边栏推荐
- 第二课第一周第4-6节 医学预后案例欣赏+作业解析
- Experiment record of Shengxin (part3)--scipy.spatial.distance_matrix
- 微信公众号后台管理
- The latest domestic power supply manufacturers and pin-to-pin replacement manuals for specific models are released
- MySQL advanced query
- Detailed explanation of the opkg of OpenWrt
- Sigma开发注意细节
- 软件测试面试题:什么是数据的对立性,有几个层次?
- 基于 HPSO 与多核 LSSVM 的网络入侵检测
- JVM类加载机制
猜你喜欢
深度解析:什么是太爱速M抢单模式?
从键入网址到网页显示的详细过程
WinForm (5) control and its members
Data Filters in ABP
MySQL八股文背诵版(续)
[The method of calling the child page from the parent page of the iframe] Stepping on the pit: It is the key to use `[x]` when getting elements. You cannot use `.eq(x)`, otherwise it will not be obtai
21、阿里云oss
阿里亿级并发册 + 机器学习算法 + 面试册 + 优化册 + 代码册 笔记!!!
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs
Deep Learning [Chapter 2]
随机推荐
OpenHarmony啃论文俱乐部-啃论文心得
OpenWrt之opkg详解
请讲一讲JS中的 for...in 与 for...of (下)
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs
22、库存服务
How to realize the repeatable design of FPGA
paddle2.3和torch1.8在SentenceBert上的性能对比
微信公众号后台管理
简陋的nuxt3学习笔记
Engineering Design of Single-sided PCB Routing Impedance
【开源】壁纸软件,给自己电脑设计专属特效
通过热透镜聚焦的高斯光束
HCIP-R&S By Wakin自用笔记(3)OSPF之引入外部路由、Forwarding-Address、汇总、特殊区域
Gaussian beam focused by thermal lens
Fatal error in launcher: Unable to create process using xxx --logdir logs(tensorboard使用)
【oops-framework】模板项目【oops-game-kit】使用简介
如何防止离职员工把企业文件拷贝带走?法律+技术,4步走
络达开发---串口日志&日志过滤
备战“金九银十”,软件测试功能 / 数据库 /linux/ 接口 / 自动化 / 测试开发面试真题解析
ARM开发(四)新手小白如何阅读芯片手册,裸机驱动开发步骤以及纯汇编实现点灯,汇编结合c点灯,c实现点灯