This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Deadlocks
Eugene Tulika edited this page Feb 2, 2018
·
3 revisions
Multiple saves of the products invoked in parallel causes database deadlocks. First place which constantly generates deadlocks is url rewrite update. Removing unique index on url_rewrite
table allows to extremely reduce the number of deadlocks.
------------------------
LATEST DETECTED DEADLOCK
------------------------
2017-11-14 16:31:09 700000b0b000
*** (1) TRANSACTION:
TRANSACTION 10926532, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 20 lock struct(s), heap size 2936, 17 row lock(s), undo log entries 13
MySQL thread id 772, OS thread handle 0x700000a83000, query id 42678 localhost root update
INSERT INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES ('0', '1', NULL, NULL, 'product', '76', 'new-name-deadlock-test-5a0b6eab33dae-attempt-0-request-1.html', 'catalog/product/view/id/76', '1')
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 524602 n bits 104 index `URL_REWRITE_STORE_ID_ENTITY_ID` of table `m2engcom_ce`.`url_rewrite` trx id 10926532 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 10926533, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
20 lock struct(s), heap size 2936, 17 row lock(s), undo log entries 13
MySQL thread id 773, OS thread handle 0x700000b0b000, query id 42679 localhost root update
INSERT INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES ('0', '1', NULL, NULL, 'product', '75', 'new-name-deadlock-test-5a0b6eab33dae-attempt-0-request-2.html', 'catalog/product/view/id/75', '1')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 524602 n bits 104 index `URL_REWRITE_STORE_ID_ENTITY_ID` of table `m2engcom_ce`.`url_rewrite` trx id 10926533 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 524602 n bits 104 index `URL_REWRITE_STORE_ID_ENTITY_ID` of table `m2engcom_ce`.`url_rewrite` trx id 10926533 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)
There are multiple approaches on how to refactor Url Rewrites so that deadlocks are avoided.
- solve the deadlocks issue by itself, arranging select and insert queries in the way that it is impossible for them to block each other
- Move out url rewrite generation in separate process which runs after all products are imported.