Jboss - 自动重新连接到 XA 数据源后出现奇怪的异常
我在 Jboss 6 上使用 XA 数据源,使用
和
在以下情况下自动重新连接其中一个连接已断开。这是可行的,但问题是,在“重新连接”之后,每隔两分钟左右我就会得到这个奇怪的异常,即使我的数据库操作正在运行。
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
会不会是司机? (我使用的是 Microsoft 的类型 4)
这是我的数据源配置:
<xa-datasource>
<jndi-name>jdbc/MyDataSourceDS</jndi-name>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
<xa-datasource-property name="ServerName">hostname</xa-datasource-property>
<xa-datasource-property name="DatabaseName">database</xa-datasource-property>
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<xa-datasource-property name="User">user</xa-datasource-property>
<xa-datasource-property name="Password">password</xa-datasource-property>
<!--pooling parameters-->
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<new-connection-sql>select 1</new-connection-sql>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</xa-datasource>
另外,我没有看到日志中每个查询之前运行的“SELECT 1”查询?我看到我的查询正在运行。
任何帮助将不胜感激!
I'm using a XA datasource on Jboss 6, using <check-valid-connection-sql>
and <background-validation-millis>
to auto-reconnect when one of the connections is dead. This works, but the problem is that after the "reconnecting", every two minutes or so I get this strange exception, even though my database operations is working.
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
Could it be the Driver? (I'm using the type 4 from Microsoft)
Here's my datasource configuration:
<xa-datasource>
<jndi-name>jdbc/MyDataSourceDS</jndi-name>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
<xa-datasource-property name="ServerName">hostname</xa-datasource-property>
<xa-datasource-property name="DatabaseName">database</xa-datasource-property>
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<xa-datasource-property name="User">user</xa-datasource-property>
<xa-datasource-property name="Password">password</xa-datasource-property>
<!--pooling parameters-->
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<new-connection-sql>select 1</new-connection-sql>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</xa-datasource>
Also, I don't see the "SELECT 1" query running before each query in the logs? I see my queries running though.
Any help will be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确理解 - 您运行的是 JBoss AS 6 还是 JBoss EAP 6?
但我提到的是 JBoss EAP 6,目前可以在 jboss.org 上下载。
我在数据库关闭后重新连接恢复过程时遇到了类似的问题,我不确定这是一个问题还是缺少一些配置。我认为这不是jdbc驱动的问题。但我可能是错的。如果我有一点时间,我会很好奇去调查这个。如果我会让你知道的话。
尽管如此 - 我的解决方法是刷新特定数据源的连接池。 jboss cli 中的命令如下:
/subsystem=datasources/xa-data-source=[datasource-name]:flush-all-connection-in-pool()
后面是什么?
事务管理器 (Narayana) 每 2 分钟启动一次恢复过程。恢复检查应用程序服务器中事务管理器一侧和数据库一侧的事务日志。它寻找需要修复的可疑交易。
恢复过程需要连接到数据库才能检查可疑事务的存在。但是当数据库关闭时,连接池*可能*仍保留旧连接。
该解决方法迫使池被刷新并再次充满新的连接。
To understand right - do you run JBoss AS 6 or JBoss EAP 6?
But I it it's talked about JBoss EAP 6 which is currently available for download at jboss.org.
I had similar trouble with re-connection of recovery process after database shutdown and I'm not sure whether it's an issue or some missing configuration. I think that's not a problem of jdbc driver. But I could be wrong. If I have a bit time I will be curious to investigate this. In case I will let you know.
Nevertheless - my workaround is to flush connection pool for the particular datasource. The command in jboss cli would be like this:
/subsystem=datasources/xa-data-source=[datasource-name]:flush-all-connection-in-pool()
What's behind?
Transaction manager (Narayana) starts process of recovery each 2 minutes. Recovery checks transaction log at the side of transaction manager in app server and at the side of database. It looks for in-doubt transactions which are needed to be fixed.
Recovery process needs to connect to database for being able to check on the existence of in-doubt transactions. But when database is shut down then connection pool * probably* stays with old connections.
The workaround force the pool being flushed and filled again with renewed connections.