users@glassfish.java.net

DB connection retry

From: Mei Wu <Mei.Wu_at_Sun.COM>
Date: Fri, 22 Feb 2008 14:35:29 -0500

In our application, we have a DB connection retry logic, i.e. whenever a
SQLException happens, we test the connection is valid or not, if not,
the connection is closed and then for every a few seconds, a new
connection is obtained from pool by :DataSource.getConnection() and
until a valid connection is obtained.
This is done without setting validation on for the Connection Pool to
avoid overhead. However, if the data source is XADataSource,
DataSource.getConnection() itself will have exception like below:

[#|2008-02-22T11:50:41.580-0500|WARNING|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=23;_ThreadName=BPELSEInOutThread5;_RequestID=c72ac31a-d53a-403a-8605-fcb92ccf3314;|JTS5041:
The resource manager is doing work outside a global transaction
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1045)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:249)
at com.sun.gjc.spi.XAResourceImpl.start(XAResourceImpl.java:222)
at
com.sun.jts.jta.TransactionState.startAssociation(TransactionState.java:305)

at com.sun.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:205)
at
com.sun.enterprise.distributedtx.J2EETransaction.enlistResource(J2EETransaction.java:562)

at
com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.enlistResource(J2EETransactionManagerImpl.java:372)

at
com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.enlistResource(J2EETransactionManagerOpt.java:144)

at
com.sun.enterprise.resource.SystemResourceManagerImpl.enlistResource(SystemResourceManagerImpl.java:98)

at
com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:216)

at
com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:337)

at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:189)

at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:165)

at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:158)

at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:108)
at
com.sun.jbi.engine.bpel.core.bpel.connection.DBConnectionFactory.createXAConnection(DBConnectionFactory.java:259)


And it seems whenever that happens and if a retry is triggered, memory
usage surges instantly causing other more severe problems. Is the memory
issue expected, do we have the another option other than enabling
validation on Connection Pool ?

Thanks
Mei