Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

MySql insert deadlock (3 replies)

$
0
0
Hi,

I encountered a deadlock for a simple insert happens occationally. The insert may be concurrent but I don't understand why below two transactions deadlock. Could anyone explain me? Thanks in advance. My MySQL version is 5.5.38

This is my table:

CREATE TABLE `group_roles` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`group_id` INT(11) NULL DEFAULT NULL,
`resource_id` INT(11) NULL DEFAULT NULL,
`role` VARCHAR(64) NOT NULL COLLATE 'utf8_bin',
PRIMARY KEY (`id`),
INDEX `group_roles_group` (`group_id`),
INDEX `group_roles_resource` (`resource_id`),
INDEX `group_roles_role` (`role`)
)
COLLATE='utf8_bin'
ENGINE=InnoDB
AUTO_INCREMENT=1074905
;


This is the dead lock information.

LATEST DETECTED DEADLOCK
------------------------
151215 8:02:51
*** (1) TRANSACTION:
TRANSACTION 50B6DA1, ACTIVE 5 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 5 lock struct(s), heap size 1248, 3 row lock(s), undo log entries 1
MySQL thread id 139481, OS thread handle 0x7f1098065700, query id 1069042902 100.81.68.131 aqc_admin update
INSERT INTO group_roles (group_id, resource_id, role)
VALUES (1, 15795590, 'admin')
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 13507866 n bits 936 index `group_roles_resource` of table `aqcsonar`.`group_roles` trx id 50B6DA1 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;;

*** (2) TRANSACTION:
TRANSACTION 50B6DA6, ACTIVE 5 sec inserting
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1248, 3 row lock(s), undo log entries 1
MySQL thread id 139485, OS thread handle 0x7f1086274700, query id 1069042917 100.81.68.218 aqc_admin update
INSERT INTO group_roles (group_id, resource_id, role)
VALUES (1, 15795591, 'admin')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 13507866 n bits 936 index `group_roles_resource` of table `aqcsonar`.`group_roles` trx id 50B6DA6 lock_mode X
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 13507866 n bits 936 index `group_roles_resource` of table `aqcsonar`.`group_roles` trx id 50B6DA6 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;;

*** WE ROLL BACK TRANSACTION (2)

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>