我们正在从Microsoft ADO.NET连接器访问MySQL。
有时,我们在innodb状态中看到以下死锁,并且无法确定问题的原因。看起来事务(2)正在等待并持有相同的锁?
------------------------
LATEST DETECTED DEADLOCK
------------------------
110606 5:35:09
*** (1) TRANSACTION:
TRANSACTION 0 45321452, ACTIVE 0 sec, OS thread id 3804 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 368, 1 row lock(s)
MySQL thread id 84, query id 3265713 localhost 127.0.0.1 famdev Updating
UPDATE people SET company_id = 1610, name = '<name>', password = '<hash>', temp_password = NULL, reset_password_hash = NULL, email = '<redacted>@yahoo.com', phone = NULL, mobile = '<phone>', iphone_device_id = 'android:<id>-<id>', iphone_device_time = '2011-06-06 05:35:09', last_checkin = '2011-06-06 05:24:42', location_lat = <lat>, location_long = -<lng>, gps_strength = 3296, picture_blob_id = 1190, authority = 1, active = 1, date_created = '2011-04-13 20:21:20', last_login = '2011-06-06 05:35:09', panic_mode = 0, battery_level = NULL, battery_state = NULL WHERE people_id = 3125
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 11144 n bits 152 index `PRIMARY` of table `family`.`people` trx id 0 45321452 lock_mode X locks rec but not gap waiting
Record lock, heap no 12 PHYSICAL RECORD: n_fields 25; compact format; info bits 0
0: len 8; hex 8000000000000c35; asc 5;; 1: len 6; hex 000002b38ce6; asc ;; 2: len 7; hex 00000002801f89; asc ;; 3: len 8; hex 800000000000064a; asc J;; 4: len 4; hex <data>; asc <name>;; 5: len 30; hex <data>; asc <data>;...(truncated); 6: SQL NULL; 7: SQL NULL; 8: len 16; hex <data>; asc <redacted>@yahoo.com;; 9: SQL NULL; 10: len 10; hex <data>; asc <phone>;; 11: len 30; hex <data>; asc android:<id>;...(truncated); 12: len 8; hex <data>; asc J] Z;; 13: len 8; hex <data>; asc J] Z;; 14: len 8; hex a39410acaa9b4340; asc C@;; 15: len 8; hex <data>; asc m S ;; 16: len 2; hex 8ce0; asc ;; 17: len 8; hex 80000000000004a6; asc ;; 18: len 4; hex 80000001; asc ;; 19: len 1; hex 81; asc ;; 20: len 8; hex <data>; asc JR ;; 21: len 8; hex <data>; asc J] ;; 22: len 1; hex 80; asc ;; 23: SQL NULL; 24: SQL NULL;
*** (2) TRANSACTION:
TRANSACTION 0 45321448, ACTIVE 0 sec, OS thread id 3176 starting index read, thread declared inside InnoDB 500
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1216, 2 row lock(s), undo log entries 1
MySQL thread id 85, query id 3265714 localhost 127.0.0.1 famdev Updating
UPDATE people SET company_id = 1610, name = '<name>', password = '<hash>', temp_password = NULL, reset_password_hash = NULL, email = '<redacted>@yahoo.com', phone = NULL, mobile = '<phone>', iphone_device_id = 'android:<id>-<id>-<id>-<id>', iphone_device_time = '2011-06-06 05:24:42', last_checkin = '2011-06-06 05:35:07', location_lat = <lat>, location_long = -<lng>, gps_strength = 3296, picture_blob_id = 1190, authority = 1, active = 1, date_created = '2011-04-13 20:21:20', last_login = '2011-06-06 05:35:09', panic_mode = 0, battery_level = NULL, battery_state = NULL WHERE people_id = 3125
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 11144 n bits 152 index `PRIMARY` of table `family`.`people` trx id 0 45321448 lock mode S locks rec but not gap
Record lock, heap no 12 PHYSICAL RECORD: n_fields 25; compact format; info bits 0
0: len 8; hex 8000000000000c35; asc 5;; 1: len 6; hex 000002b38ce6; asc ;; 2: len 7; hex 00000002801f89; asc ;; 3: len 8; hex 800000000000064a; asc J;; 4: len 4; hex <data>; asc <name>;; 5: len 30; hex <data>; asc <data>;...(truncated); 6: SQL NULL; 7: SQL NULL; 8: len 16; hex <data>; asc <redacted>@yahoo.com;; 9: SQL NULL; 10: len 10; hex <data>; asc <phone>;; 11: len 30; hex <data>; asc android:<id>;...(truncated); 12: len 8; hex <data>; asc J] Z;; 13: len 8; hex <data>; asc J] Z;; 14: len 8; hex a39410acaa9b4340; asc C@;; 15: len 8; hex <data>; asc m S ;; 16: len 2; hex 8ce0; asc ;; 17: len 8; hex 80000000000004a6; asc ;; 18: len 4; hex 80000001; asc ;; 19: len 1; hex 81; asc ;; 20: len 8; hex <data>; asc JR ;; 21: len 8; hex <data>; asc J] ;; 22: len 1; hex 80; asc ;; 23: SQL NULL; 24: SQL NULL;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 11144 n bits 152 index `PRIMARY` of table `family`.`people` trx id 0 45321448 lock_mode X locks rec but not gap waiting
Record lock, heap no 12 PHYSICAL RECORD: n_fields 25; compact format; info bits 0
0: len 8; hex 8000000000000c35; asc 5;; 1: len 6; hex 000002b38ce6; asc ;; 2: len 7; hex 00000002801f89; asc ;; 3: len 8; hex 800000000000064a; asc J;; 4: len 4; hex <data>; asc <name>;; 5: len 30; hex <data>; asc <data>;...(truncated); 6: SQL NULL; 7: SQL NULL; 8: len 16; hex <data>; asc <redacted>@yahoo.com;; 9: SQL NULL; 10: len 10; hex <data>; asc <phone>;; 11: len 30; hex <data>; asc android:<id>;...(truncated); 12: len 8; hex <data>; asc J] Z;; 13: len 8; hex <data>; asc J] Z;; 14: len 8; hex a39410acaa9b4340; asc C@;; 15: len 8; hex <data>; asc m S ;; 16: len 2; hex 8ce0; asc ;; 17: len 8; hex 80000000000004a6; asc ;; 18: len 4; hex 80000001; asc ;; 19: len 1; hex 81; asc ;; 20: len 8; hex <data>; asc JR ;; 21: len 8; hex <data>; asc J] ;; 22: len 1; hex 80; asc ;; 23: SQL NULL; 24: SQL NULL;
*** WE ROLL BACK TRANSACTION (1)
我们已阅读了有关下一个键锁定的文章,但它似乎不适用于我们,因为我们没有进行选择更新。
更新资料
今天早上,我发现了一个稍有不同的死锁签名,这可能是造成此死锁的根本原因。我将死锁发布为一个单独的问题,以使事情变得简单。如果可以确认另一个问题是原因,请在此处进行更新。