有一段时间了,我的mysql在执行一个语句时,总是有一部分数据不能正常执行,错误报:
#1213 - Deadlock found when trying to get lock; try restarting transaction
但我如何找出问题并解决问题呢?
show engine innodb status得出入下:| InnoDB |      | 
=====================================
130823 18:30:34 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 12 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 30276 1_second, 30276 sleeps, 2698 10_second, 3364 background, 3364 flush
srv_master_thread log flush and writes: 30490
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 2907, signal count 39331
Mutex spin waits 742501, rounds 433525, OS waits 1068
RW-shared spins 12563, rounds 70843, OS waits 1566
RW-excl spins 908, rounds 34497, OS waits 248
Spin rounds per wait: 0.58 mutex, 5.64 RW-shared, 37.99 RW-excl
------------------------
LATEST DETECTED DEADLOCK
------------------------
130823 16:55:27
*** (1) TRANSACTION:
TRANSACTION E71F28, ACTIVE 0 sec fetching rows
mysql tables in use 6, locked 6
LOCK WAIT 226 lock struct(s), heap size 31160, 4 row lock(s), undo log entries 1
MySQL thread id 104177, OS thread handle 0x7feb18d04700, query id 8785682 localhost root Sending data
call InvDtInsertData(new.rdcode,new.cinvcode,new.cbatch,new.cmadedate,new.iposition,new.iquantity,date_format(new.pdate,'%Y%m%d'))
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 4489 n bits 416 index `ck_view_ix1` of table `cenkon`.`ck_view_tab` trx id E71F28 lock_mode X locks rec but not gap waiting
Record lock, heap no 345 PHYSICAL RECORD: n_fields 6; compact format; info bits 0
 0: len 3; hex 4c5343; asc LSC;;
 1: len 6; hex 415541303032; asc AUA002;;
 2: len 6; hex 4d4532373130; asc ME2710;;
 3: len 6; hex 323031363035; asc 201605;;
 4: len 0; hex ; asc ;;
 5: len 4; hex 80011ef4; asc     ;;*** (2) TRANSACTION:
TRANSACTION E71F1E, ACTIVE 0 sec fetching rows, thread declared inside InnoDB 73
mysql tables in use 6, locked 6
280 lock struct(s), heap size 31160, 4 row lock(s), undo log entries 2
MySQL thread id 102991, OS thread handle 0x7feb161e2700, query id 8785685 localhost root Updating
update ck_view_tab
      set iquantity = iquantity +  NAME_CONST('nQuantity',0.00000000),
          iquantityIn = iquantityIn +  NAME_CONST('nQuantityIn',0.00000000),
          iquantityOut = iquantityOut +  NAME_CONST('nQuantityOut',0.00000000),
          iquantityInT1 = iquantityInT1 +  NAME_CONST('nQuantityInT1',0.00000000),
          iquantityOutT1 = iquantityOutT1 +  NAME_CONST('nQuantityOutT1',0.00000000),
          pdate =  NAME_CONST('dPdate',NULL)
      where if((isnull(cwhcode) or length(cwhcode)=0),'null',cwhcode) = if((isnull( NAME_CONST('sCwhcode',_utf8'LSC' COLLATE 'utf8_general_ci')) or length( NAME_CONST('sCwhcode',_utf8'LSC' COLLATE 'utf8_general_ci'))=0),'null', NAME_CONST('sCwhcode',_utf8'LSC' COLLATE 'utf8_general_ci'))
      and   if((isnull(cinvcode) or length(cinvcode)=0),'null',cinvcode) = if((isnull( NAME_CONST('new_cinvcode_',_utf8'AUA002' COLLATE 'utf8_general_ci')) or length( 
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 4489 n bits 416 index `ck_view_ix1` of table `cenkon`.`ck_view_tab` trx id E71F1E lock_mode X locks rec but not gap
Record lock, heap no 345 PHYSICAL RECORD: n_fields 6; compact format; info bits 0
 0: len 3; hex 4c5343; asc LSC;;
 1: len 6; hex 415541303032; asc AUA002;;
 2: len 6; hex 4d4532373130; asc ME2710;;
 3: len 6; hex 323031363035; asc 201605;;
 4: len 0; hex ; asc ;;
 5: len 4; hex 80011ef4; asc     ;;*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 82747 n bits 168 index `PRIMARY` of table `cenkon`.`ck_view_tab` trx id E71F1E lock_mode X locks rec but not gap waiting
Record lock, heap no 71 PHYSICAL RECORD: n_fields 15; compact format; info bits 0
 0: len 4; hex 80013d12; asc   = ;;
 1: len 6; hex 000000e5dd50; asc      P;;
 2: len 7; hex ad00009717011d; asc        ;;
 3: len 3; hex 4c5343; asc LSC;;
 4: len 7; hex 32323133322d42; asc 22132-B;;
 5: len 6; hex 4d4832303137; asc MH2017;;
 6: len 8; hex 3230313330383230; asc 20130820;;
 7: len 0; hex ; asc ;;
 8: SQL NULL;
 9: len 17; hex 8000000000000000000000013101312d00; asc             1 1- ;;
 10: len 17; hex 8000000000000000000000000000000000; asc                  ;;
 11: len 17; hex 8000000000000000000000000000000000; asc                  ;;
 12: len 17; hex 8000000000000000000000000000000000; asc                  ;;
 13: len 17; hex 8000000000000000000000000000000000; asc                  ;;
 14: len 1; hex 20; asc  ;;*** WE ROLL BACK TRANSACTION (1)
------------
TRANSACTIONS
------------
Trx id counter E73686
Purge done for trx's n:o < E735AA undo n:o < 0
History list length 2789
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 118003, OS thread handle 0x7fe8cc74d700, query id 9548226 10.3.3.5 cenkon01
---TRANSACTION 0, not started
MySQL thread id 117810, OS thread handle 0x7fe8cc8d1700, query id 9548253 localhost root
show engine innodb status
--------
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
17573 OS file reads, 69786 OS file writes, 19200 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 18, seg size 20, 1291 merges
merged operations:
 insert 1825, delete  1135, delete 0
discarded operations:
 insert 0, delete  0, delete 0
Hash table size 17700857, node heap has 1110 buffer(s)
45.83 hash searches/s, 1.83 non-hash searches/s
---
LOG
---
Log sequence number 5054847469
Log flushed up to   5054847469
Last checkpoint at  5054847469
0 pending log writes, 0 pending chkp writes
15036 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 8791261184; in additional pool allocated 0
Dictionary memory allocated 2430284
Buffer pool size   524288
Free buffers       497649
Database pages     25529
Old database pages 9443
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 89, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 25020, created 509, written 61719
0.00 reads/s, 0.00 creates/s, 0.00 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: 25529, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread process no. 15094, id 140647644784384, state: waiting for server activity
Number of rows inserted 22997, updated 14194, deleted 1090, read 862487903
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 46.50 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
 |
+--------+------+--------------------请各位帮我分析一下,或者给个方法,我能定位到是哪里的错误,并解决这些存在的错误。
谢谢大家。