2

I'm getting MySQL deadlock errors from time to time. it seems that a transaction is holding and waiting on the same record lock. How could that possibly happen?

------------------------
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

ez z
  • 21
  • 1
  • Does this answer your question? [How to avoid mysql 'Deadlock found when trying to get lock; try restarting transaction'](https://stackoverflow.com/questions/2332768/how-to-avoid-mysql-deadlock-found-when-trying-to-get-lock-try-restarting-trans) – danblack Mar 28 '21 at 03:51

0 Answers0