我通过" SHOW INNODB STATUS"收到了以下死锁日志。有人可以解释为什么交易被中止了吗?似乎事务2持有锁,但是仍然卡住请求相同的锁(除了"等待"部分),这在事务1也需要它时导致死锁。
=====================================
160518 9:29:18 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 39 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 14132958 1_second, 14132775 sleeps, 1413295 10_second, 0 background, 0 flush
srv_master_thread log flush and writes: 14721316
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 2455151257, signal count 47654067916
Mutex spin waits 37909510994, rounds 80118534301, OS waits 733633655
RW-shared spins 4793233766, rounds 33266305107, OS waits 530484103
RW-excl spins 1634009439, rounds 138067494036, OS waits 1055576032
Spin rounds per wait: 2.11 mutex, 6.94 RW-shared, 84.50 RW-excl
------------------------
LATEST DETECTED DEADLOCK
------------------------
160518 8:30:02
*** (1) TRANSACTION:
TRANSACTION BBAB5EDD04, ACTIVE 2 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 16 lock struct(s), heap size 3112, 593 row lock(s)
MySQL thread id 28455422311, OS thread handle 0x2b5ea7185700, query id 173542708853 ip-10-106-12-151.eu-west-1.compute.internal 10.106.12.151 jquery Updating
UPDATE `tests` SET `startOnDate` = 0 WHERE 1463560200 >= `startOnDate` AND `startOnDate` > 0
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 17891 page no 28 n bits 112 index `PRIMARY` of table `jquery`.`tests` trx id BBAB5EDD04 lock_mode X waiting
Record lock, heap no 12 PHYSICAL RECORD: n_fields 41; compact format; info bits 0
0: len 4; hex 80001755; asc U;;
1: len 6; hex 00971913ed3b; asc ;;;
2: len 7; hex 5b000b22292a84; asc [ ")* ;;
3: len 10; hex 555053454c4c20504843; asc UPSELL PHC;;
4: len 4; hex 80000032; asc 2;;
5: len 1; hex 80; asc ;;
6: len 4; hex 800004f0; asc ;;
7: len 30; hex 687474703a2f2f7777772e70686f746f626f782e66722f73686f702f7570; asc http://www.photobox.fr/shop/up; (total 73 bytes);
8: len 1; hex 01; asc ;;
9: len 4; hex 80000000; asc ;;
10: len 4; hex 80000000; asc ;;
11: len 4; hex 80000000; asc ;;
12: len 21; hex 63686c6f652e6d61756d6f6e742c61726368697665; asc chloe.maumont,archive;;
13: len 30; hex 393762306638373331353864363932343966323161373639656262396537; asc 97b0f873158d69249f21a769ebb9e7; (total 32 bytes);
14: len 4; hex d65f392a; asc _9*;;
15: len 1; hex 81; asc ;;
16: len 0; hex ; asc ;;
17: len 30; hex 3c70207374796c653d22666f6e742d66616d696c793a20617269616c3b20; asc <p style="font-family: arial; ; (total 1293 bytes);
18: len 0; hex ; asc ;;
19: len 4; hex 80000000; asc ;;
20: len 4; hex 80000000; asc ;;
21: len 4; hex 80000000; asc ;;
22: len 4; hex 80000000; asc ;;
23: len 4; hex 80000000; asc ;;
24: len 6; hex 2b30313a3030; asc +01:00;;
25: len 4; hex 50a512fa; asc P ;;
26: len 4; hex 80000001; asc ;;
27: len 0; hex ; asc ;;
28: len 1; hex 30; asc 0;;
29: len 4; hex 80000000; asc ;;
30: len 4; hex 8000acfa; asc ;;
31: len 8; hex 8000124ccfebfb26; asc L &;;
32: len 4; hex 80000000; asc ;;
33: len 0; hex ; asc ;;
34: len 4; hex 80000000; asc ;;
35: SQL NULL;
36: SQL NULL;
37: len 8; hex 8000000000000000; asc ;;
38: len 1; hex 01; asc ;;
39: len 1; hex 01; asc ;;
40: SQL NULL;
*** (2) TRANSACTION:
TRANSACTION BBAB5F26FB, ACTIVE 0 sec starting index read
mysql tables in use 4, locked 4
38 lock struct(s), heap size 6960, 245 row lock(s)
MySQL thread id 28455422293, OS thread handle 0x2b5e98df0700, query id 173542733376 ip-10-106-12-151.eu-west-1.compute.internal 10.106.12.151 jquery Sending data
INSERT IGNORE INTO `accounts_goals_patterns` (`accID`,`condType`,`condition`) SELECT (SELECT clientID FROM tests WHERE id = (SELECT testID
FROM goals_multiurl WHERE id = t1.goalMultiurlID))
AS accID, goalTypeID, `condition` FROM goals_multiurl_conditions AS t1 group by accID, goalTypeID, `condition`
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 17891 page no 28 n bits 112 index `PRIMARY` of table `jquery`.`tests` trx id BBAB5F26FB lock mode S locks rec but not gap
Record lock, heap no 12 PHYSICAL RECORD: n_fields 41; compact format; info bits 0
0: len 4; hex 80001755; asc U;;
1: len 6; hex 00971913ed3b; asc ;;;
2: len 7; hex 5b000b22292a84; asc [ ")* ;;
3: len 10; hex 555053454c4c20504843; asc UPSELL PHC;;
4: len 4; hex 80000032; asc 2;;
5: len 1; hex 80; asc ;;
6: len 4; hex 800004f0; asc ;;
7: len 30; hex 687474703a2f2f7777772e70686f746f626f782e66722f73686f702f7570; asc http://www.photobox.fr/shop/up; (total 73 bytes);
8: len 1; hex 01; asc ;;
9: len 4; hex 80000000; asc ;;
10: len 4; hex 80000000; asc ;;
11: len 4; hex 80000000; asc ;;
12: len 21; hex 63686c6f652e6d61756d6f6e742c61726368697665; asc chloe.maumont,archive;;
13: len 30; hex 393762306638373331353864363932343966323161373639656262396537; asc 97b0f873158d69249f21a769ebb9e7; (total 32 bytes);
14: len 4; hex d65f392a; asc _9*;;
15: len 1; hex 81; asc ;;
16: len 0; hex ; asc ;;
17: len 30; hex 3c70207374796c653d22666f6e742d66616d696c793a20617269616c3b20; asc <p style="font-family: arial; ; (total 1293 bytes);
18: len 0; hex ; asc ;;
19: len 4; hex 80000000; asc ;;
20: len 4; hex 80000000; asc ;;
21: len 4; hex 80000000; asc ;;
22: len 4; hex 80000000; asc ;;
23: len 4; hex 80000000; asc ;;
24: len 6; hex 2b30313a3030; asc +01:00;;
25: len 4; hex 50a512fa; asc P ;;
26: len 4; hex 80000001; asc ;;
27: len 0; hex ; asc ;;
28: len 1; hex 30; asc 0;;
29: len 4; hex 80000000; asc ;;
30: len 4; hex 8000acfa; asc ;;
31: len 8; hex 8000124ccfebfb26; asc L &;;
32: len 4; hex 80000000; asc ;;
33: len 0; hex ; asc ;;
34: len 4; hex 80000000; asc ;;
35: SQL NULL;
36: SQL NULL;
37: len 8; hex 8000000000000000; asc ;;
38: len 1; hex 01; asc ;;
39: len 1; hex 01; asc ;;
40: SQL NULL;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 17891 page no 11 n bits 136 index `PRIMARY` of table `jquery`.`tests` trx id BBAB5F26FB lock mode S locks rec but not gap waiting
Record lock, heap no 4 PHYSICAL RECORD: n_fields 41; compact format; info bits 0
0: len 4; hex 800000ed; asc ;;
1: len 6; hex 0097190dd1cc; asc ;;
2: len 7; hex 47000af2930e49; asc G I;;
3: len 18; hex 7777772e6c6977696f2e636f6d2f7474276b; asc www.liwio.com/tt'k;;
4: len 4; hex 80000053; asc S;;
5: len 1; hex 80; asc ;;
6: len 4; hex 80000001; asc ;;
7: len 23; hex 687474703a2f2f7777772e6c6977696f2e636f6d2f7474; asc http://www.liwio.com/tt;;
8: len 1; hex 01; asc ;;
9: len 4; hex 80000002; asc ;;
10: len 4; hex 80000007; asc ;;
11: len 4; hex 80000004; asc ;;
12: len 4; hex 74657374; asc test;;
13: len 30; hex 353339666435336235396533626231326432303366343561393132656561; asc 539fd53b59e3bb12d203f45a912eea; (total 32 bytes);
14: len 4; hex d65f3911; asc _9 ;;
15: len 1; hex 81; asc ;;
16: len 30; hex 0a24282768746d6c3a65712830293e626f64793a65712830293e6469763a; asc $('html:eq(0)>body:eq(0)>div:; (total 207 bytes);
17: len 30; hex 3c6272202f3e0a746573743c696d6720616c743d2222207372633d222f69; asc <br /> test<img alt="" src="/i; (total 222 bytes);
18: len 0; hex ; asc ;;
19: len 4; hex 80000000; asc ;;
20: len 4; hex 80000000; asc ;;
21: len 4; hex 80000000; asc ;;
22: len 4; hex 80000000; asc ;;
23: len 4; hex 80000000; asc ;;
24: len 6; hex 2b30313a3030; asc +01:00;;
25: len 4; hex 00000000; asc ;;
26: len 4; hex 80000001; asc ;;
27: len 0; hex ; asc ;;
28: len 1; hex 30; asc 0;;
29: len 4; hex 80000000; asc ;;
30: len 4; hex 800000e5; asc ;;
31: len 8; hex 8000124a705e8c84; asc Jp^ ;;
32: len 4; hex 80000000; asc ;;
33: len 0; hex ; asc ;;
34: len 4; hex 80000000; asc ;;
35: SQL NULL;
36: SQL NULL;
37: len 8; hex 8000000000000000; asc ;;
38: len 1; hex 01; asc ;;
39: len 1; hex 01; asc ;;
40: SQL NULL;
*** WE ROLL BACK TRANSACTION (1)
&#13;