Mysql插入和删除时死锁

标签 mysql transactions deadlock

*** (1) TRANSACTION:
TRANSACTION 11483466026, ACTIVE 5 sec inserting
mysql tables in use 34, locked 34
LOCK WAIT 176 lock struct(s), heap size 30248, 20326 row lock(s), undo log entries 10
MySQL thread id 210354334, OS thread handle 0x7ff5164da700, query id 2592552034 104.199.153.156 surelabs Sending data
INSERT INTO avt_spot VALUES (9447690,9447690,1575,'2021-05-06','',30,-1,0,8380,52773,-1,2,0,0,(select deal_item_net_rate from sky_deal_item where core_service_id =65101),125,0,0,0,0,65101,0,125,'','','',2,-1,0,9046,'',125,(select spot_display_id from sky_external_spot where core_service_id = 9447690),'ORIGINAL',0,NULL,'2019-10-29 12:10:04',NULL,1,(select priority from sky_external_spot where core_service_id = 9447690)),(9447691,9447691,1575,'2021-05-04','',30,-1,0,8380,52773,-1,2,0,0,(select deal_item_net_rate from sky_deal_item where core_service_id =65101),125,0,0,0,0,65101,0,125,'','','',2,-1,0,9046,'',125,(select spot_display_id from sky_external_spot where core_service_id = 9447691),'ORIGINAL',0,NULL,'2019-10-29 12:10:04',NULL,1,(select priority from sky_external_spot where core_service_id = 9447691)),(9447692,9447692,1575,'2021-04-27','',30,-1,0,8380,52773,-1,2,0,0,(select deal_item_net
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 151793 page no 9 n bits 224 index `fk__avt_spot__allocated_to_campaign__idx` of table `aviator_dev_db`.`avt_spot` trx id 11483466026 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 86 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902915; asc       ) ;;

*** (2) TRANSACTION:
TRANSACTION 11483471184, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
18 lock struct(s), heap size 2936, 32 row lock(s), undo log entries 12
MySQL thread id 210356075, OS thread handle 0x7ff511cea700, query id 2592571282 104.199.153.156 surelabs updating
delete from `sky_external_spot` where `id` in ('490662', '490663', '490664', '490665', '490666')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 151793 page no 9 n bits 224 index `fk__avt_spot__allocated_to_campaign__idx` of table `aviator_dev_db`.`avt_spot` trx id 11483471184 lock_mode X
Record lock, heap no 86 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902915; asc       ) ;;

Record lock, heap no 87 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902916; asc       ) ;;

Record lock, heap no 88 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902917; asc       ) ;;

Record lock, heap no 90 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902918; asc       ) ;;

Record lock, heap no 92 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 000020bd; asc     ;;
 1: len 8; hex 0000000000902919; asc       ) ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 151926 page no 251 n bits 192 index `PRIMARY` of table `aviator_dev_db`.`sky_external_spot` trx id 11483471184 lock_mode X locks rec but not gap waiting
Record lock, heap no 110 PHYSICAL RECORD: n_fields 23; compact format; info bits 0
 0: len 8; hex 8000000000077ca6; asc       | ;;
 1: len 6; hex 0002ac7798eb; asc    w  ;;
 2: len 7; hex 2f000045eb106b; asc /  E  k;;
 3: len 8; hex 80000000000005b7; asc         ;;
 4: len 8; hex 8000000000001848; asc        H;;
 5: len 8; hex 8000000000902916; asc       ) ;;
 6: len 8; hex 800000000000001e; asc         ;;
 7: len 2; hex 3735; asc 75;;
 8: len 2; hex 3735; asc 75;;
 9: len 4; hex 8000f679; asc    y;;
 10: len 1; hex 30; asc 0;;
 11: len 3; hex 8fca7f; asc    ;;
 12: len 8; hex 8000000000000394; asc         ;;
 13: len 3; hex 815000; asc  P ;;
 14: len 3; hex 816000; asc  ` ;;
 15: len 10; hex 4d2d462039702d313070; asc M-F 9p-10p;;
 16: len 2; hex 3735; asc 75;;
 17: len 4; hex 00000002; asc     ;;
 18: len 4; hex 7fffffff; asc     ;;
 19: len 1; hex 80; asc  ;;
 20: len 4; hex 80000001; asc     ;;
 21: len 4; hex 80000005; asc     ;;
 22: len 1; hex 31; asc 1;;

*** WE ROLL BACK TRANSACTION (2)

谁能帮我理解这一点

最佳答案

” 我认为这些日志是原始格式的,我认为下面的文章将帮助您更好地理解这些日志,以找出谁在锁定数据库中的表:https://www.xaprb.com/blog/2006/07/31/how-to-analyze-innodb-mysql-locks/

关于Mysql插入和删除时死锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58603390/

相关文章:

mysql - COALESCE() 用于空白(但不是空)字段

php - Codeigniter:将 form_input 插入 sql 表

java - 同步方法与mysql连接池创建死锁

去 channel 死锁问题

mysql - 从 PL SQL 错误 ORA-28536 : error in processing Heterogeneous Services initialization parameters 更新 mysql 表

mysql - datetime MySQL 解析日期

mysql - 为什么mysql查询需要表锁隔离读未提交?

hibernate 回滚

java - 为什么我会收到 "createCriteria is not valid without active transaction"异常?

mysql - 莫名其妙的 InnoDB 死锁