开发者

Jboss - Strange exception after auto-reconnecting to XA datasource

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-mi开发者_开发百科llis>
    <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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜