尝试锁定时发现死锁

时间:2015-01-06 09:40:16

标签: mysql database vb.net innodb deadlock

我经常遇到这个例外。

  

2015-Jan-06 14:24:59.167(SEVERE)在试图获得时发现死锁   lock [0] System.Exception消息=尝试获取时发现的死锁   lock Source = Data.ResultAccumulator

我的应用程序是VB.Net应用程序,我正在使用MySQL连接.Net版本6.8.3

在DataAdapter.Update方法中使用DataTable进行批量更新时,我收到此异常。 整个更新过程在Transactions中运行。

我找到了这个例外的各种线程,用户建议分析Innodb状态。所以我在获得此异常后已取得状态。但我不知道如何分析它。这是innodb的状态。

=====================================
2015-01-06 14:25:07 2ec INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 29 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 7208 srv_active, 0 srv_shutdown, 74547 srv_idle
srv_master_thread log flush and writes: 81579
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 3583
OS WAIT ARRAY INFO: signal count 4766
Mutex spin waits 3514, rounds 53287, OS waits 1608
RW-shared spins 2281, rounds 46994, OS waits 1262
RW-excl spins 1304, rounds 36969, OS waits 674
Spin rounds per wait: 15.16 mutex, 20.60 RW-shared, 28.35 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 1859662
Purge done for trx's n:o < 1859649 undo n:o < 0 state: running but idle
History list length 1653
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 1859651, not started
MySQL thread id 127, OS thread handle 0xb00, query id 140079 N0414LEDF0275 10.0.52.40 opkeyapi cleaning up
---TRANSACTION 1859446, not started
MySQL thread id 98, OS thread handle 0xf9c, query id 140081 localhost 127.0.0.1 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 97, OS thread handle 0x1c28, query id 140080 localhost 127.0.0.1 root cleaning up
---TRANSACTION 1859658, not started
MySQL thread id 107, OS thread handle 0x1f78, query id 140109 N0414LEDF0240 10.0.52.129 opkeyapi cleaning up
---TRANSACTION 1859652, not started
MySQL thread id 102, OS thread handle 0xed4, query id 140085 N0414LEDF0240 10.0.52.129 opkeyapi cleaning up
---TRANSACTION 0, not started
MySQL thread id 90, OS thread handle 0x1f60, query id 81724 localhost 127.0.0.1 root cleaning up
---TRANSACTION 1859634, not started
MySQL thread id 46, OS thread handle 0x159c, query id 140015 N0414LEDF0065 10.0.52.133 opkeyapi cleaning up
---TRANSACTION 1859633, not started
MySQL thread id 45, OS thread handle 0x1464, query id 140011 N0414LEDF0065 10.0.52.133 opkeyapi cleaning up
---TRANSACTION 1859630, not started
MySQL thread id 42, OS thread handle 0x1c00, query id 139999 N0414LEDF0250 10.0.52.128 opkeyapi cleaning up
---TRANSACTION 1859629, not started
MySQL thread id 41, OS thread handle 0x1768, query id 139995 N0414LEDF0250 10.0.52.128 opkeyapi cleaning up
---TRANSACTION 1859649, not started
MySQL thread id 38, OS thread handle 0x1ac8, query id 140071 N0414LEDF0085 10.0.52.63 opkeyapi cleaning up
---TRANSACTION 1859650, not started
MySQL thread id 36, OS thread handle 0x17d8, query id 140075 N0414LEDF0085 10.0.52.63 opkeyapi cleaning up
---TRANSACTION 1859661, ACTIVE 0 sec
39 lock struct(s), heap size 2496, 100 row lock(s), undo log entries 224
MySQL thread id 126, OS thread handle 0x2ec, query id 140356 N0414LEDF0275 10.0.52.40 opkeyapi init
show engine innodb status
Trx read view will not see trx with id >= 1859662, sees < 1859662
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: wait Windows aio (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (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
22934 OS file reads, 39569 OS file writes, 9117 OS fsyncs
3.07 reads/s, 16384 avg bytes/read, 0.55 writes/s, 0.38 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 36, seg size 38, 2078 merges
merged operations:
 insert 16494, delete mark 25, delete 2
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 1602143, node heap has 366 buffer(s)
53.93 hash searches/s, 61.00 non-hash searches/s
---
LOG
---
Log sequence number 4140114089
Log flushed up to   4139522989
Pages flushed up to 4138539042
Last checkpoint at  4138539042
0 pending log writes, 0 pending chkp writes
5282 log i/o's done, 0.17 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 410091520; in additional pool allocated 0
Dictionary memory allocated 608237
Buffer pool size   24704
Free buffers       1024
Database pages     23314
Old database pages 8586
Modified db pages  249
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 9750, not young 279685
0.59 youngs/s, 19.55 non-youngs/s
Pages read 22848, created 10791, written 32759
3.07 reads/s, 3.28 creates/s, 0.31 writes/s
Buffer pool hit rate 993 / 1000, young-making rate 1 / 1000 not 50 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 23314, unzip_LRU len: 0
I/O sum[15]:cur[77], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 2656, state: sleeping
Number of rows inserted 21162, updated 2520, deleted 131, read 48116841
7.48 inserts/s, 0.31 updates/s, 0.00 deletes/s, 53.38 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

任何人都可以告诉我调试此问题的方法,以便我可以找到它的修复程序。

1 个答案:

答案 0 :(得分:0)

您问题中的状态不包含任何死锁信息,因此您无法在死锁后立即使用它。
可能是服务器在您处于状态之前已重新启动<登记/> 状态必须包含一个看起来像这个例子的部分:

------------------------
LATEST DETECTED DEADLOCK
------------------------
2015-01-06 11:47:02 da8
*** (1) TRANSACTION:
TRANSACTION 24103246, ACTIVE 16 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s)
MySQL thread id 3, OS thread handle 0xde8, query id 102 localhost 127.0.0.1 test
 updating
update test set test=1 where test=1
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 489 page no 3 n bits 80 index `PRIMARY` of table `test`.`t
est` trx id 24103246 lock_mode X locks rec but not gap waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 4; hex 80000001; asc     ;;
 1: len 6; hex 0000016fc940; asc    o @;;
 2: len 7; hex a80000026e0110; asc     n  ;;

*** (2) TRANSACTION:
TRANSACTION 24103245, ACTIVE 63 sec starting index read, thread declared inside
InnoDB 5000
mysql tables in use 1, locked 1
3 lock struct(s), heap size 376, 2 row lock(s)
MySQL thread id 4, OS thread handle 0xda8, query id 103 localhost 127.0.0.1 test
 updating
update test set test=4 where test=4
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 489 page no 3 n bits 80 index `PRIMARY` of table `test`.`t
est` trx id 24103245 lock_mode X locks rec but not gap
Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 4; hex 80000001; asc     ;;
 1: len 6; hex 0000016fc940; asc    o @;;
 2: len 7; hex a80000026e0110; asc     n  ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 489 page no 3 n bits 80 index `PRIMARY` of table `test`.`t
est` trx id 24103245 lock_mode X locks rec but not gap waiting
Record lock, heap no 5 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 4; hex 80000004; asc     ;;
 1: len 6; hex 0000016fc940; asc    o @;;
 2: len 7; hex a80000026e0137; asc     n 7;;

*** WE ROLL BACK TRANSACTION (2)
------------
TRANSACTIONS
------------