我将mysql与Hibernate
和Spring HibernateTransactionManager
一起使用。
我的mysql连接将在ACTIVE
中,但没有死锁。
这是我的例外:
(deallock问题和fk问题已修复!)
java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2334)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2262)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2246)
这是我的show engine innodb status
:
=====================================
140829 13:53:06 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 2 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 4284857 1_second, 4284854 sleeps, 42740 10_second, 27639 background, 27639 flush
srv_master_thread log flush and writes: 483491
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 20783, signal count 101656
Mutex spin waits 884986, rounds 328183, OS waits 297
RW-shared spins 133015, rounds 3335038, OS waits 9873
RW-excl spins 149331, rounds 1801472, OS waits 10558
Spin rounds per wait: 0.37 mutex, 25.07 RW-shared, 12.06 RW-excl
------------------------
LATEST FOREIGN KEY ERROR
------------------------
140825 16:22:01 Error in foreign key constraint of table lecheng/queqiaocontactmap:
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
or one of the ON ... SET NULL columns is declared NOT NULL. Constraint:
,
CONSTRAINT "FK_SourcePhone_QueQiaoUser_MobilePhone" FOREIGN KEY ("SourcePhone") REFERENCES "queqiaouser" ("MobilePhone")
InnoDB: Renaming table `lecheng`.<result 2 when explaining filename '#sql-fec1_11b1b'> to `lecheng`.`queqiaocontactmap` failed!
--------
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
76318 OS file reads, 3117868 OS file writes, 2121530 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 0, seg size 2, 7853 merges
merged operations:
insert 18211, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 398509, node heap has 2402 buffer(s)
422.29 hash searches/s, 305.35 non-hash searches/s
---
LOG
---
Log sequence number 13792623435
Log flushed up to 13792623435
Last checkpoint at 13792623425
Max checkpoint age 254092862
Checkpoint age target 246152461
Modified age 10
Checkpoint age 10
0 pending log writes, 0 pending chkp writes
1871119 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 206831616; in additional pool allocated 0
Internal hash tables (constant factor + variable factor)
Adaptive hash index 42546656 (3188072 + 39358584)
Page hash 200104 (buffer pool 0 only)
Dictionary cache 920688 (798704 + 121984)
File system 105552 (82672 + 22880)
Lock system 502944 (499064 + 3880)
Recovery system 0 (0 + 0)
Dictionary memory allocated 121984
Buffer pool size 12287
Buffer pool size, bytes 201310208
Free buffers 0
Database pages 9885
Old database pages 3628
Modified db pages 1
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 235515, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 76480, created 24158, written 1653633
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: 9885, unzip_LRU len: 0
I/O sum[48]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
---OLDEST VIEW---
Normal read view
Read view low limit trx n:o 10BA769
Read view up limit trx id 10B7F81
Read view low limit trx id 10BA769
Read view individually stored trx ids:
Read view trx id 10BA768
Read view trx id 10B7F81
-----------------
Main thread process no. 65217, id 47009759495936, state: sleeping
Number of rows inserted 3176797, updated 3343797, deleted 525, read 159208727079
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 329.84 reads/s
------------------------
LATEST DETECTED DEADLOCK
------------------------
140822 11:36:41
*** (1) TRANSACTION:
TRANSACTION 4E7F35, ACTIVE 2 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 4 lock struct(s), heap size 1248, 4 row lock(s), undo log entries 3
MySQL thread id 162, OS thread handle 0x2ac168081700, query id 354356 10.129.26.73 que_qiao_prd Updating
update QueQiaoContactMap set CreatedDate='2014-08-21 15:00:10', Deleted=0, Depth=1, RelatedOrder=27, SourcePhone='18621763191', TargetPhone='12345678909', UpdatedDate='2014-08-21 15:00:10' where Id=556148
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 411 page no 1964 n bits 280 index `PRIMARY` of table `lecheng`.`queqiaocontactmap` trx id 4E7F35 lock_mode X locks rec but not gap waiting
*** (2) TRANSACTION:
TRANSACTION 4E7F34, ACTIVE 2 sec starting index read
mysql tables in use 1, locked 1
24 lock struct(s), heap size 6960, 105 row lock(s), undo log entries 104
MySQL thread id 163, OS thread handle 0x2ac198040700, query id 355037 10.129.26.73 que_qiao_prd Updating
update QueQiaoContactMap set CreatedDate='2014-08-21 00:00:08', Deleted=0, Depth=1, RelatedOrder=26, SourcePhone='18621763191', TargetPhone='13512020637', UpdatedDate='2014-08-22 11:36:41' where Id=553563
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 411 page no 1964 n bits 280 index `PRIMARY` of table `lecheng`.`queqiaocontactmap` trx id 4E7F34 lock_mode X locks rec but not gap
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 411 page no 1951 n bits 280 index `PRIMARY` of table `lecheng`.`queqiaocontactmap` trx id 4E7F34 lock_mode X locks rec but not gap waiting
*** WE ROLL BACK TRANSACTION (1)
------------
TRANSACTIONS
------------
Trx id counter 10BA8C5
Purge done for trx's n:o < 10BA75E undo n:o < 0
History list length 448
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 162504, OS thread handle 0x2ac208081700, query id 225736226 10.143.34.171 dozer47528
show engine innodb status
---TRANSACTION 10B80FA, not started
MySQL thread id 162420, OS thread handle 0x2ac18c081700, query id 225489110 10.129.26.73 que_qiao_prd
---TRANSACTION 10B80FB, not started
MySQL thread id 162361, OS thread handle 0x2ac1fc040700, query id 225489115 10.129.26.73 que_qiao_prd
---TRANSACTION 10B6F32, not started
MySQL thread id 162360, OS thread handle 0x2ac13bf6b700, query id 225643712 10.129.26.73 que_qiao_prd
---TRANSACTION 10B9629, not started
MySQL thread id 162342, OS thread handle 0x2ac18c040700, query id 225631689 10.129.26.73 que_qiao_prd
---TRANSACTION 10BA1A3, not started
MySQL thread id 162338, OS thread handle 0x2ac198040700, query id 225696625 10.129.26.73 que_qiao_prd
---TRANSACTION 10BA8C4, ACTIVE 0 sec
MySQL thread id 149135, OS thread handle 0x2ac1dc081700, query id 225736218 10.129.26.73 que_qiao_prd
---TRANSACTION 10B7F81, ACTIVE 295 sec
10 lock struct(s), heap size 1248, 165 row lock(s), undo log entries 1284
MySQL thread id 162341, OS thread handle 0x2ac1fc081700, query id 225736192 10.129.26.73 que_qiao_prd
TABLE LOCK table `lecheng`.`queqiaocontactmap` trx id 10B7F81 lock mode IX
TABLE LOCK table `lecheng`.`queqiaocontactmappath` trx id 10B7F81 lock mode IX
TABLE LOCK table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode IS
RECORD LOCKS space id 318 page no 5 n bits 160 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 11 n bits 168 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 7 n bits 160 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 8 n bits 160 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 4 n bits 168 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 12 n bits 120 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
RECORD LOCKS space id 318 page no 10 n bits 160 index `PRIMARY` of table `lecheng`.`queqiaouser` trx id 10B7F81 lock mode S locks rec but not gap
TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS
----------------------------
END OF INNODB MONITOR OUTPUT
============================