RECORD LOCKS space id 10236 page no 4 n bits 72 index tg_user_id of table `test`.Sequelize with MySql can throw Deadlock found when trying to get lock. *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 10236 page no 4 n bits 72 index tg_user_id of table `test`.`tg_users` trx id 293922 lock_mode X TRANSACTION 293922, ACTIVE 15 sec insertingģ lock struct(s), heap size 1080, 2 row lock(s), undo log entries 1 Record lock, heap no 1 PHYSICAL RECORD: n_fields 1 compact format info bits 0Ġ: len 7072656d756d asc supremum RECORD LOCKS space id 10236 page no 4 n bits 72 index tg_user_id of table `test`.`tg_users` trx id 293921 lock_mode X insert intention waiting *** (1) WAITING FOR THIS LOCK TO BE GRANTED: ON DUPLICATE KEY UPDATE `id`=LAST_INSERT_ID(`id`) LOCK WAIT 3 lock struct(s), heap size 1080, 2 row lock(s), undo log entries 1 TRANSACTION 293921, ACTIVE 24 sec inserting Why does the query in step 3 get blocking? Even though the row in step 3 is not involved in connection 2 (which is issuing IX lock).ĭeadlock Report from SHOW ENGINE INNODB STATUS.ERROR 1213 (40001): Deadlock found when trying to get lock try restarting transaction (Step 4) Back to connection 2 and insert (why it gets deadlock?) (uniq identity: 239302521) INSERT INTO `tg_users` (Step 3) Back to connection 1 and insert (why is it blocking?) (uniq identity: 341292662) INSERT INTO `tg_users` (uniq identity: 239302521) START TRANSACTION įROM `tg_users` WHERE `tg_user_id` = '239302521' FOR UPDATE (Step 2) Open Connection 2 and do select query. Keep connection 1 open, create connection 2. (uniq identity: 341292662) START TRANSACTION Reproduction Steps: - (Step 1) Open Connection 1 and do select query. (so I think the row lock is not relevant since they are working with different row). Connection 1 and connection 2 have different tg_user_id on its queries. Just to emphasize things that may be important to check: If the such data exists, then compare and update.If the user has not been stored in database, then insert it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |