mysql - MySQL 在同一条记录上死锁
问题描述
我不时收到 MySQL 死锁错误。似乎一个事务正在持有并等待同一个记录锁。这怎么可能发生?
------------------------
LATEST DETECTED DEADLOCK
------------------------
2021-03-28 02:05:00 2b89b1836700
*** (1) TRANSACTION:
TRANSACTION 22774383040, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 376, 1 row lock(s)
MySQL thread id 4862793, OS thread handle 0x2b83dfb8a700, query id 18125913470 manhattanowner statistics
select * from tb_ride where id=3857302 for update
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 224 page no 70133 n bits 98 index `PRIMARY` of table `Manhattan`.`tb_ride` trx id 22774383040 lock_mode X locks rec but not gap waiting
Record lock, heap no 98 PHYSICAL RECORD: n_fields 26; compact format; info bits 0
*** (2) TRANSACTION:
TRANSACTION 22774382499, ACTIVE 1 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s)
MySQL thread id 4862794, OS thread handle 0x2b89b0e77700, query id 18125912089
select * from tb_ride where id=3857302 for update
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 224 page no 70133 n bits 98 index `PRIMARY` of table `Manhattan`.`tb_ride` trx id 22774382499 lock_mode X locks rec but not gap
Record lock, heap no 98 PHYSICAL RECORD: n_fields 26; compact format; info bits 0
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 224 page no 70133 n bits 98 index `PRIMARY` of table `Manhattan`.`tb_ride` trx id 22774382499 lock_mode X locks rec but not gap waiting
Record lock, heap no 98 PHYSICAL RECORD: n_fields 26; compact format; info bits 0
解决方案
推荐阅读
- angular - 带有 Angular + Springboot 的 Whitelabel 错误页面
- javascript - 单击按钮后抓取活动元素
- postcss - 运行顺风/ postcss
- x86 - 如何最有效地存储 __m128i/__m256i 的一部分,同时从开头/结尾忽略一些元素
- python - 带有 pyspark 的多标签
- nginx - 无法从 Web 访问运行 NGINXon 阿里巴巴 ECS
- python - Python中函数的并行执行
- javascript - Javascript - 替换除最后一个分隔符之外的所有分隔符
- google-data-studio - 在 THEN 中带有超链接公式的 CASE 未加载,有时会出现错误(问题不稳定,数据工作室有问题)
- python - 我只想使用 pyqt5 在 QTableWidget 中单击第一列