表中的并发插入导致死锁

时间:2014-07-06 13:44:23

标签: mysql database transactions innodb deadlock

我正在使用mysql和parellel处理。当我尝试插入表格时导致死锁。所以当我使用

进行分析时

SHOW ENGINE INNODB STATUS;

它给了我以下结果

Type,Name,Status InnoDB,"","

2014-07-06 06:11:30 7f4528572700 INNODB MONITOR OUTPUT

LATEST DETECTED DEADLOCK

2014-07-06 06:06:10 7f4b200ab700

 (1) TRANSACTION: TRANSACTION 4861937180, ACTIVE 0 sec starting index read 

  mysql tables in use 1, locked 1 

  LOCK WAIT 18 lock struct(s), heap size 2936, 12 row lock(s), undo log entries 105 

  MySQL thread id 54025237, OS thread handle 0x7f4530121700, query id 175469449   Sending data 

  SELECT cnxcntrc.nxt_ctsy_bill_no,nxt_bill_no FROM cnxcntrc for update

@@@ (1) WAITING FOR THIS LOCK TO BE GRANTED: 

    RECORD LOCKS space id 194838 page no 3 n bits 72 index `GEN_CLUST_INDEX` of table `sdsusawdb`.`cnxcntrc` trx id 4861937180 lock_mode X waiting 

    Record lock, heap no 2 PHYSICAL RECORD: n_fields 34; compact format; info bits 0 

    0: len 6; hex 00016c2c99f6; asc   l,  ;;  

    1: len 6; hex 000121cb469e; asc   ! F ;;  

    2: len 7; hex 7b0002403a02d4; asc {  @:  ;;  

    3: len 30; hex 53616e20446965676f20537461746520556e697665727369747920412f52; asc San Diego State University A/R;; 

    4: len 12; hex 432020202020202020202020; asc C           ;;  

    5: len 3; hex 8fbccf; asc    ;;  

    6: len 4; hex 80044d37; asc   M7;;  

    7: len 4; hex 80c1e0d8; asc     ;;  

    8: len 4; hex 80754330; asc  uC0;;  

    9: len 4; hex 7ff559eb; asc   Y ;;  

    10: len 4; hex 80004d25; asc   M%;;  

    11: len 4; hex 80000b0e; asc     ;;  

    12: len 1; hex 59; asc Y;;  

    13: len 3; hex 8f9ae1; asc    ;;  

    14: len 14; hex 53554d2f44544c20202020202020; asc SUM/DTL       ;;  

    15: len 14; hex 44414e2d53554d2d464c41472020; asc DAN-SUM-FLAG  ;;  

    16: len 14; hex 434153482d434c41535320202020; asc CASH-CLASS    ;;  

    17: len 14; hex 46495343414c2d59454152202020; asc FISCAL-YEAR   ;;  

    18: len 14; hex 2020202020202020202020202020; asc               ;;  

    19: len 14; hex 43555252454e544c4556454c2020; asc CURRENTLEVEL  ;;  

    20: len 14; hex 2020202020202020202020202020; asc               ;;  

    21: len 14; hex 5350454350524f47202020202020; asc SPECPROG      ;;  

    22: len 14; hex 4f50544f55542020202020202020; asc OPTOUT        ;;  

    23: len 14; hex 4531303938542020202020202020; asc E1098T        ;;  

    24: len 14; hex 4641435354414646202020202020; asc FACSTAFF      ;;  

    25: len 14; hex 4641435354414646444154452020; asc FACSTAFFDATE  ;;  

    26: len 20; hex 2020202020202020202020202020202020202020; asc                     ;;  

    27: len 20; hex 2020202020202020202020202020202020202020; asc      ;;  

    28: len 1; hex 59; asc Y;;  

    29: len 2; hex 8028; asc  (;;  

    30: len 3; hex 202020; asc    ;;  

    31: len 7; hex 99934c60a01018; asc   L`   ;; 

    32: len 7; hex 99934c60a00ee2; asc   L`   ;;  

    33: len 7; hex 9992e8b96a0816; asc     j  ;;

@@@ (2) TRANSACTION: TRANSACTION 4861937310, ACTIVE 0 sec inserting 

        mysql tables in use 1, locked 1 

        9 lock struct(s), heap size 1184, 5 row lock(s), undo log entries 5 

        MySQL thread id 54025256, OS thread handle 0x7f4b200ab700, query id 175469982  update 

        INSERT INTO cnoopenr (bill_no, bill_cust_code, bill_org_cust_code, serv_cust_code, serv_org_cust_code, source_inv_code, source_module, source_system, source_tx_no, bal_fwd_group, bal_fwd_sub_group, purch_ord_no, tran_code, create_date, last_mod_date, pause_bill_date, eff_date, due_date, hold_date, session_code, creator_code, creator_id, creator_no, bill_min_due, bill_orig_amt, bill_balance, bill_status, collection_status, fa_apply_auth_flag) VALUES ('7684911', '801000028', '801000028', '801000028', '801000028', NULL, 'FC', 'EXTED', '12706034', NULL, '', '', NULL, '2014-07-06', '2014-07-06', '', '2014-06-15', '2014-07-11', '2014-07-18', '30243E', 'FC', '', '0', '0', '741.00', '741.00', 'O', 'A', 'N')

@@@ (2) HOLDS THE LOCK(S): 

        RECORD LOCKS space id 194838 page no 3 n bits 72 index `GEN_CLUST_INDEX` of table `sdsusawdb`.`cnxcntrc` trx id 4861937310 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;;

    Record lock, heap no 2 PHYSICAL RECORD: n_fields 34; compact format; info bits 0

    0: len 6; hex 00016c2c99f6; asc   l,  ;;  

    1: len 6; hex 000121cb469e; asc   ! F ;;  

    2: len 7; hex 7b0002403a02d4; asc {  @:  ;;  

    3: len 30; hex 53616e20446965676f20537461746520556e697665727369747920412f52; asc San Diego State University A/R;;  

    4: len 12; hex 432020202020202020202020; asc C           ;;  

    5: len 3; hex 8fbccf; asc    ;;  

    6: len 4; hex 80044d37; asc   M7;;  

    7: len 4; hex 80c1e0d8; asc     ;;  

    8: len 4; hex 80754330; asc  uC0;;  

    9: len 4; hex 7ff559eb; asc   Y ;;  

    10: len 4; hex 80004d25; asc   M%;;  

    11: len 4; hex 80000b0e; asc     ;;  

    12: len 1; hex 59; asc Y;;  

    13: len 3; hex 8f9ae1; asc    ;;  

    14: len 14; hex 53554d2f44544c20202020202020; asc SUM/DTL       ;;  

    15: len 14; hex 44414e2d53554d2d464c41472020; asc DAN-SUM-FLAG  ;;  

    16: len 14; hex 434153482d434c41535320202020; asc CASH-CLASS    ;;  

    17: len 14; hex 46495343414c2d59454152202020; asc FISCAL-YEAR   ;;  

    18: len 14; hex 2020202020202020202020202020; asc               ;;  

    19: len 14; hex 43555252454e544c4556454c2020; asc CURRENTLEVEL  ;;  

    20: len 14; hex 2020202020202020202020202020; asc               ;;  

    21: len 14; hex 5350454350524f47202020202020; asc SPECPROG      ;;  

    22: len 14; hex 4f50544f55542020202020202020; asc OPTOUT        ;;  

    23: len 14; hex 4531303938542020202020202020; asc E1098T        ;;  

    24: len 14; hex 4641435354414646202020202020; asc FACSTAFF      ;;  

    25: len 14; hex 4641435354414646444154452020; asc FACSTAFFDATE  ;;  

    26: len 20; hex 2020202020202020202020202020202020202020; asc                     ;;  

    27: len 20; hex 2020202020202020202020202020202020202020; asc      ;;  

    28: len 1; hex 59; asc Y;;  

    29: len 2; hex 8028; asc  (;;  

    30: len 3; hex 202020; asc    ;;  

    31: len 7; hex 99934c60a01018; asc   L`   ;; 

    32: len 7; hex 99934c60a00ee2; asc   L`   ;;  

    33: len 7; hex 9992e8b96a0816; asc     j  ;;

@@@ (2) WAITING FOR THIS LOCK TO BE GRANTED: 

RECORD LOCKS space id 194783 page no 2949 n bits 344 index `cnoopenr_5` of table `sdsusawdb`.`cnoopenr` trx id 4861937310 lock_mode X locks gap before rec insert intention waiting 

Record lock, heap no 169 PHYSICAL RECORD: n_fields 4; compact format; info bits 0  

    0: len 16; hex 38303130303030323820202020202020; asc 801000028       ;; 

    1: len 12; hex 333032343345202020202020; asc 30243E      ;;  

    2: len 8; hex 4643414e54202020; asc FCANT   ;;  

    3: len 6; hex 00017234fb94; asc   r4 ;;

@@@ WE ROLL BACK TRANSACTION (2)

TRANSACTIONS

Trx id counter 4862018881 

Purge done for trx's n:o < 4862018873 undo n:o < 0 state: running but idle 

History list length 1600 

LIST OF TRANSACTIONS FOR EACH SESSION:

TRANSACTION 0, not started 

    MySQL thread id 54103662, OS thread handle 0x7f4528572700, query id 175565704 172.28.1.3 usrsdsuadmin init 

    SHOW ENGINE INNODB STATUS

TRANSACTION 4862018879, not started 

    MySQL thread id 54096024, OS thread handle 0x7f45295f3700, query id 175565700 172.28.1.3 wiki52usr cleaning up

TRANSACTION 4862008754, not started 

    MySQL thread id 54096023, OS thread handle 0x7f4529120700, query id 175565673 172.28.1.3 wiki52usr cleaning up

TRANSACTION 862008748, not started 

    MySQL thread id 54096025, OS thread handle 0x7f45286b7700, query id 175554579 172.28.1.3 wiki52usr cleaning up

TRANSACTION 4862008738, not started 

    MySQL thread id 54081336, OS thread handle 0x7f452901c700, query id 175554515 172.28.1.3 wiki52usr cleaning up

INSERT BUFFER AND ADAPTIVE HASH INDEX

Ibuf: size 1, free list len 29410, seg size 29412, 90418 merges 

merged operations:  

    insert 173057, delete mark 79056, delete 12983 

discarded operations:  

    insert 0, delete mark 0, delete 0 

    Hash table size 46749601, node heap has 29886 buffer(s)

9.00 hash searches/s, 16.00 non-hash searches/s

Log sequence number 3029681089859 

Log flushed up to   3029681089751 

Pages flushed up to 3029681089449 

Last checkpoint at  3029681089449 0 pending log writes, 0 pending chkp writes 6326294 log i/o's done, 1.10 log i/o's/second

END OF INNODB MONITOR OUTPUT

我如何用这些来解决僵局。非常感谢任何帮助。

0 个答案:

没有答案