Wildfly 9.0.1上与数据库连接失败后的事务超时

时间:2016-04-05 12:10:55

标签: hibernate postgresql timeout wildfly connection-timeout

我试图在连接失败后中止挂起的事务或查询。我通过插入网线来模拟连接失败(wildfly坐在本地,db在远程服务器上)。

我尝试了几种配置,使用验证检查器和两个数据库,oracle:

<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"></valid-connection-checker>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"></stale-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"></exception-sorter>
<background-validation>true</background-validation>
<background-validation-millis>5000</background-validation-millis>

和postgresql:

<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>

我还尝试设置事务管理器服务,这里收到了一些输出:

12:43:15,059 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff7f000101:-19fa369e:5703967d:12 in state  RUN
12:43:15,061 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012095: Abort of action id 0:ffff7f000101:-19fa369e:5703967d:12 invoked while multiple threads active within it.
12:43:15,061 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012108: CheckedAction::check - atomic action 0:ffff7f000101:-19fa369e:5703967d:12 aborting with 1 threads active!
12:43:15,560 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff7f000101:-19fa369e:5703967d:12 in state  CANCEL
12:43:15,562 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012378: ReaperElement appears to be wedged: sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)
java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:224)
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.lock(BaseWrapperManagedConnection.java:383)
org.jboss.jca.adapters.jdbc.local.LocalManagedConnection.rollback(LocalManagedConnection.java:122)
org.jboss.jca.core.tx.jbossts.LocalXAResourceImpl.rollback(LocalXAResourceImpl.java:248)
com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource.rollback(XAOnePhaseResource.java:205)
com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord.topLevelAbort(LastResourceRecord.java:126)
com.arjuna.ats.arjuna.coordinator.BasicAction.doAbort(BasicAction.java:2993)
com.arjuna.ats.arjuna.coordinator.BasicAction.doAbort(BasicAction.java:2972)
com.arjuna.ats.arjuna.coordinator.BasicAction.Abort(BasicAction.java:1675)
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.cancel(TwoPhaseCoordinator.java:127)
com.arjuna.ats.arjuna.AtomicAction.cancel(AtomicAction.java:215)
com.arjuna.ats.arjuna.coordinator.TransactionReaper.doCancellations(TransactionReaper.java:381)
com.arjuna.ats.internal.arjuna.coordinator.ReaperWorkerThread.run(ReaperWorkerThread.java:78)
12:43:16,062 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff7f000101:-19fa369e:5703967d:12 in state  CANCEL_INTERRUPTED
12:43:16,062 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012120: TransactionReaper::check worker Thread[Transaction Reaper Worker 0,5,main] not responding to interrupt when cancelling TX 0:ffff7f000101:-19fa369e:5703967d:12 -- worker marked as zombie and TX scheduled for mark-as-rollback
12:43:16,063 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012110: TransactionReaper::check successfuly marked TX 0:ffff7f000101:-19fa369e:5703967d:12 as rollback only

我认为获得锁定的问题可能是原因,但不知道如何解决它。我可以添加数据库连接是使用hibernates Session进行的。 Hibernate的版本是5.0.0

我也尝试了查询超时

<timeout>
    <query-timeout>60</query-timeout>
</timeout>

令人惊讶的是,它仅在没有连接失败时才有效。 我做错了什么?

0 个答案:

没有答案