Hi !
I’m using MySQL 5.5 INNODB, on Amazon RDS ,
recently almost every day I got a deadlock.
When I check the server with ‘SHOW ENGINE INNODB STATUS’ , I see that the deadlock caused by 2 transactions :
LATEST DETECTED DEADLOCK
141230 1:09:27
*** (1) TRANSACTION:
TRANSACTION 69880, ACTIVE 80 sec fetching rows
mysql tables in use 2, locked 2
LOCK WAIT 10852 lock struct(s), heap size 981432, 401304 row lock(s)
MySQL thread id 217497, OS thread handle 0x2b30ef700, query id 1429148
INSERT INTO tmp_table
SELECT x,
y,
FROM PRTable
WHERE
date > DATE_SUB(now(), INTERVAL 31 DAY)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2565513 page no 383779 n bits 120 index PRIMARY
of table A3UPWUL52
.PRTable
trx id 692BA80 lock mode S waiting
Record lock, heap no 41 PHYSICAL RECORD: n_fields 49; compact format; info bits 0
*** (2) TRANSACTION:
TRANSACTION 69E831, ACTIVE 7 sec inserting
mysql tables in use 5, locked 5
117 lock struct(s), heap size 14776, 2411 row lock(s), undo log entries 792
MySQL thread id 23332, OS thread handle 0x2b2ac2f700, query id 1432667 Sending data
insert into PRTable (…)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 256213 page no 323779 n bits 120 index PRIMARY
of table A3UPWUL52
.
PRTable
trx id 6922A80 lock_mode X locks rec but not gap
Record lock, heap no 41 PHYSICAL RECORD: n_fields 49; compact format; info bits 0
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 275513 page no 383779 n bits 128 index PRIMARY
of table A3UPWUL52
.
PRTable
trx id 6922A80 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 41 PHYSICAL RECORD: n_fields 49; compact format; info bits 0
*** WE ROLL BACK TRANSACTION (2)
I read about gap-locking and tried to set isolation in amazon parameter group to READ-COMMITTED , but it didn’t help.
The variable innodb_locks_unsafe_for_binlog is uneditable in amazon , so I can’t change it to 1.
What Can I do to solve it? There is option that MySQL restart the transaction after the ROLL BACK done?
Thank you!!