有時即時得到問題的鎖定,如鎖定:問題與交易與Hibernate 4.0
java.sql.SQLTransactionRollbackException: A lock could not be obtained within the time requested
我使用的是c3p0池休眠,並設置爲樂觀鎖定休眠。
我也有一些代碼繞過Hibernate,並通過獨立配置的c3p0池與數據庫交談。這純粹是因爲這個代碼在我轉移到Hibernate之前就已經存在,並且工作得很好,所以我沒有必要在當時改變它。
現在我想知道是否有兩個獨立配置的c3p0池可能會導致問題。如果不是,我如何才能追蹤這些異常的原因,我將池設置爲20到100個連接,並且我最多隻有12個線程併發,並且我認爲當我完成所有事務/會話時,它們都將被關閉。
編輯:現在有一個游泳池,但仍然得到一個問題,流汗以下錯誤,但沒有詳細說明,以它的原因,有一件事艾韋注意到的是,它總是說託管線程:3
Exception with lookup
12:42:36,627 WARN ThreadPoolAsynchronousRunner:608 - com[email protected]1ff96a2 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
12:42:36,628 WARN ThreadPoolAsynchronousRunner:624 - com[email protected]1ff96a2 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
co[email protected]fdfb9a (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
co[email protected]914847 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
co[email protected]205390 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
Pending Tasks:
co[email protected]4e171b
com.mchange.[email protected]ceeecb
com.mchange.[email protected]19f7cec
com.mchange.[email protected]1c299f9
[email protected]0ab38a
[email protected]916a2f
com.mchange.[email protected]1d23fbf
com.mchange.v2.[email protected]
com.mchange.[email protected]1027733
com.mchange.[email protected]dfd9b0
[email protected]cecbb
co[email protected]4a0d0b
com.mchange.[email protected]19e809d
[email protected]0de0f8
[email protected]ce568
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,JAIKOZ Thread Group]
org.apache.derby.impl.jdbc.EmbedStatement.close(Unknown Source)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,JAIKOZ Thread Group]
org.apache.derby.impl.jdbc.EmbedStatement.close(Unknown Source)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,JAIKOZ Thread Group]
org.apache.derby.impl.jdbc.EmbedStatement.close(Unknown Source)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
這可能是此問題
https://forum.hibernate.org/viewtopic.php?p=2390809
如果更好的話,我可以移動到h2 – 2012-04-18 14:58:15
H2支持多版本併發。它應該有助於避免使用下面的示例中的互斥鎖和鎖。這可能不會傷害嘗試。 – 2012-04-18 15:13:23