mysql deadlock处理

1、SHOW ENGINE INNODB STATUS 

得到最后一次死锁发生的状况


=====================================
140110 11:43:07 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 54 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 5037089 1_second, 5036991 sleeps, 489026 10_second, 175730 background, 175732 flush
srv_master_thread log flush and writes: 5081825
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 1709867, signal count 1885463
Mutex spin waits 90823196, rounds 141024951, OS waits 1091052
RW-shared spins 389947, rounds 10020949, OS waits 326347
RW-excl spins 30685, rounds 7751684, OS waits 243881
Spin rounds per wait: 1.55 mutex, 25.70 RW-shared, 252.62 RW-excl
------------------------
LATEST DETECTED DEADLOCK
------------------------
140110 9:29:27
*** (1) TRANSACTION:
TRANSACTION 3E74124, ACTIVE 0 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 133 lock struct(s), heap size 14776, 7029 row lock(s), undo log entries 6
MySQL thread id 33528585, OS thread handle 0x7f618327a700, query id 633587738 tb-0 xxxx  xx Updating
update ics_item set crawler_store="184", crawler_cprice="699.00", crawler_mprice="1299.00" where crawler_cid="xxxx" and skuid="xxx"
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 8021 n bits 128 index `crawler_item_id` of table `mal`.`ics_item` trx id 3E74124 lock_mode X waiting
Record lock, heap no 26 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 70 bytes);
1: len 6; hex 000003e7412b; asc A+;;
2: len 7; hex 120003b5b71a83; asc ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 5; hex 38392e3030; asc 89.00;;
10: len 6; hex 3231392e3030; asc 219.00;;
11: len 2; hex 3737; asc 77;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4cf7; asc R L ;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3335303939383836303031; asc 35099886001;;

*** (2) TRANSACTION:
TRANSACTION 3E7412B, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1248, 7 row lock(s), undo log entries 14
MySQL thread id 33528192, OS thread handle 0x7f6198d20700, query id 633587747 tb-0 xxxx xxxxx update
replace into ics_item(crawler_url,crawler_level,crawler_cat,skuid,crawler_itmes,crawler_discount,title,url,crawler_groupid,crawler_store,crawler_mprice,crawler_item_id,crawler_cid,crawler_cprice) values ('http://detail.tmall.com/item.htm?id=23238668423','0','nvzhuang','39356618809','23238668423','0','AYQ_NULL','AYQ_NULL','tb_tonlionbailaohui_23238668423','0','0','tb_tonlionbailaohui_23238668423_A款中牛仔蓝_31合金头光身','tb_tonlionbailaohui','0')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 8021 n bits 128 index `crawler_item_id` of table `mal`.`ics_item` trx id 3E7412B lock_mode X locks rec but not gap
Record lock, heap no 26 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 70 bytes);
1: len 6; hex 000003e7412b; asc A+;;
2: len 7; hex 120003b5b71a83; asc ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 5; hex 38392e3030; asc 89.00;;
10: len 6; hex 3231392e3030; asc 219.00;;
11: len 2; hex 3737; asc 77;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4cf7; asc R L ;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3335303939383836303031; asc 35099886001;;

Record lock, heap no 27 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 55 bytes);
1: len 6; hex 000003e7412b; asc A+;;
2: len 7; hex 120003b5b71bb9; asc ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 1; hex 30; asc 0;;
10: len 1; hex 30; asc 0;;
11: len 1; hex 30; asc 0;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4cf7; asc R L ;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3335303939383836303032; asc 35099886002;;

Record lock, heap no 34 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 55 bytes);
1: len 6; hex 000003e7412b; asc A+;;
2: len 7; hex 120003b5b71f81; asc ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 1; hex 30; asc 0;;
10: len 1; hex 30; asc 0;;
11: len 1; hex 30; asc 0;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4cf7; asc R L ;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3436343332313936363336; asc 46432196636;;

Record lock, heap no 43 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 67 bytes);
1: len 6; hex 000003e7412b; asc A+;;
2: len 7; hex 120003b5b720b1; asc ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 5; hex 38392e3030; asc 89.00;;
10: len 6; hex 3231392e3030; asc 219.00;;
11: len 1; hex 30; asc 0;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4cf7; asc R L ;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3339333536363138383133; asc 39356618813;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 8021 n bits 128 index `crawler_item_id` of table `mal`.`ics_item` trx id 3E7412B lock_mode X locks rec but not gap waiting
Record lock, heap no 61 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 70 bytes);
1: len 6; hex 000003e6ea2b; asc +;;
2: len 7; hex 540003b4eb2206; asc T " ;;
3: len 23; hex 74616f62616f5f746f6e6c696f6e6261696c616f687569; asc tb_tonlionbailaohui;;
4: len 30; hex 74616f62616f5f746f6e6c696f6e6261696c616f6875695f323332333836; asc tb_tonlionbailaohui_232386; (total 35 bytes);
5: len 11; hex 3233323338363638343233; asc 23238668423;;
6: len 8; hex 6e767a6875616e67; asc nvzhuang;;
7: len 30; hex 687474703a2f2f64657461696c2e746d616c6c2e636f6d2f6974656d2e68; asc http://detail.tmall.com/item.h; (total 47 bytes);
8: len 1; hex 30; asc 0;;
9: len 5; hex 38392e3030; asc 89.00;;
10: len 6; hex 3231392e3030; asc 219.00;;
11: len 3; hex 313631; asc 161;;
12: len 1; hex 30; asc 0;;
13: len 4; hex 52cf4660; asc R F`;;
14: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
15: len 8; hex 4159515f4e554c4c; asc AYQ_NULL;;
16: len 11; hex 3339333536363138383039; asc 39356618809;;

*** WE ROLL BACK TRANSACTION (2)
------------
TRANSACTIONS
------------
Trx id counter 3E8BDB8
Purge done for trx's n:o < 310B52E undo n:o < 0
History list length 4697388
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 3E86DE4, not started
MySQL thread id 33585831, OS thread handle 0x7f61833d1700, query id 634207431 192.168.179.238 xxxx
---TRANSACTION 3E86241, not started
MySQL thread id 33582256, OS thread handle 0x7f6198a72700, query id 634160664 192.168.179.238 xxxx
---TRANSACTION 3E838BD, not started
MySQL thread id 33575239, OS thread handle 0x7f6183e77700, query id 634100781 192.168.179.238 xxxx
---TRANSACTION 0, not started
MySQL thread id 33575086, OS thread handle 0x7f618358a700, query id 634207418 192.168.179.238 xxxx
---TRANSACTION 3E786E9, not started
MySQL thread id 33542360, OS thread handle 0x7f6198ad4700, query id 634385966 192.168.179.238 xxxx
show engine INNOdb status
---TRANSACTION 3E8BBEA, ACTIVE 2 sec
MySQL thread id 33603606, OS thread handle 0x7f619b3d0700, query id 634384254 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBEB, sees < 310B376
---TRANSACTION 3E8BBE9, ACTIVE 2 sec
MySQL thread id 33603604, OS thread handle 0x7f6198888700, query id 634384251 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBEA, sees < 310B376
---TRANSACTION 3E8BBE8, ACTIVE 2 sec
MySQL thread id 33603605, OS thread handle 0x7f619b39f700, query id 634384253 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBE9, sees < 310B376
---TRANSACTION 3E8BBA2, ACTIVE 3 sec
MySQL thread id 33603554, OS thread handle 0x7f6198aa3700, query id 634384004 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBA3, sees < 310B376
---TRANSACTION 3E8BBA1, ACTIVE 3 sec
MySQL thread id 33603552, OS thread handle 0x7f619b4c5700, query id 634384002 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBA2, sees < 310B376
---TRANSACTION 3E8BBA0, ACTIVE 3 sec
MySQL thread id 33603553, OS thread handle 0x7f618302e700, query id 634384003 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBA1, sees < 310B376
---TRANSACTION 3E8BB9F, ACTIVE 3 sec
MySQL thread id 33603551, OS thread handle 0x7f6182d4f700, query id 634383991 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BBA0, sees < 310B376
---TRANSACTION 3E8BB9E, ACTIVE 3 sec
MySQL thread id 33603549, OS thread handle 0x7f61985a9700, query id 634383989 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BB9F, sees < 310B376
---TRANSACTION 3E8BB9D, ACTIVE 3 sec
MySQL thread id 33603550, OS thread handle 0x7f6198b05700, query id 634383990 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3E8BB9E, sees < 310B376
---TRANSACTION 3E8B953, ACTIVE 17 sec
MySQL thread id 33603034, OS thread handle 0x7f61832dc700, query id 634381140 tb-0 192.168.39.73 xxxx
Trx read view will not see trx with id >= 3E8B954, sees < 310B376
---TRANSACTION 3E8ACC5, ACTIVE 136 sec
MySQL thread id 33600215, OS thread handle 0x7f61982ca700, query id 634363655 tb-1 192.168.20.139 xxxx
Trx read view will not see trx with id >= 3E8ACC6, sees < 310B376
---TRANSACTION 3E8AC7C, ACTIVE 153 sec
MySQL thread id 33600114, OS thread handle 0x7f6198b67700, query id 634362426 tb-1 192.168.20.139 xxxx
Trx read view will not see trx with id >= 3E8AC7D, sees < 310B376
---TRANSACTION 3E8AC2F, ACTIVE 175 sec
MySQL thread id 33599989, OS thread handle 0x7f6183433700, query id 634360899 tb-0 192.168.39.73 xxxx
Trx read view will not see trx with id >= 3E8AC30, sees < 310B376
---TRANSACTION 3E8ABFD, ACTIVE 190 sec
MySQL thread id 33599884, OS thread handle 0x7f619b33d700, query id 634359645 tb-1 192.168.20.139 xxxx
Trx read view will not see trx with id >= 3E8ABFE, sees < 310B376
---TRANSACTION 3E8AB2E, ACTIVE 244 sec
MySQL thread id 33599557, OS thread handle 0x7f6198a41700, query id 634355470 tb-1 192.168.20.139 xxxx
Trx read view will not see trx with id >= 3E8AB2F, sees < 310B376
---TRANSACTION 3E8AA50, ACTIVE 286 sec
MySQL thread id 33599314, OS thread handle 0x7f61ac15c700, query id 634352163 tb-0 192.168.39.73 xxxx
Trx read view will not see trx with id >= 3E8AA51, sees < 310B376
---TRANSACTION 3E8AA3E, ACTIVE 289 sec
MySQL thread id 33599303, OS thread handle 0x7f619894c700, query id 634351973 tb-0 192.168.39.73 xxxx
Trx read view will not see trx with id >= 3E8AA3F, sees < 310B376
---TRANSACTION 3DD805E, ACTIVE 61904 sec
MySQL thread id 32943048, OS thread handle 0x7f61836b0700, query id 634368570 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3DD805F, sees < 310B376
---TRANSACTION 3DC185A, ACTIVE 68485 sec
MySQL thread id 32868525, OS thread handle 0x7f6198a10700, query id 634369806 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 3DC185B, sees < 310B376
---TRANSACTION 310B376, ACTIVE 1183998 sec
MySQL thread id 24750327, OS thread handle 0x7f6183528700, query id 634381400 tb-0 192.168.40.55 xxxx
Trx read view will not see trx with id >= 310B377, sees < 310ACB9
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
564228 OS file reads, 38055934 OS file writes, 23850234 OS fsyncs
0.11 reads/s, 16384 avg bytes/read, 9.06 writes/s, 6.74 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 5, seg size 7, 70178 merges
merged operations:
insert 609318, delete mark 996925, delete 1
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 276707, node heap has 167 buffer(s)
58.48 hash searches/s, 72.70 non-hash searches/s
---
LOG
---
Log sequence number 33629011958
Log flushed up to 33629011958
Last checkpoint at 33628515027
0 pending log writes, 0 pending chkp writes
22211235 log i/o's done, 5.83 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 137363456; in additional pool allocated 0
Dictionary memory allocated 756138
Buffer pool size 8192
Free buffers 0
Database pages 8025
Old database pages 2942
Modified db pages 286
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1161805, not young 0
0.22 youngs/s, 0.00 non-youngs/s
Pages read 589345, created 432818, written 39117888
0.11 reads/s, 0.37 creates/s, 10.87 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 8025, unzip_LRU len: 0
I/O sum[562]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
21 read views open inside InnoDB
Main thread process no. 29920, id 140057187231488, state: sleeping
Number of rows inserted 21764830, updated 60731284, deleted 21287860, read 674064958694
0.00 inserts/s, 15.80 updates/s, 0.00 deletes/s, 1012.81 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

原文地址:https://www.cnblogs.com/DjangoBlog/p/3513444.html