Bug #14279 Idle timeouts cause XAConnections to whine about rolling themselves back
Submitted: 25 Oct 2005 0:41 Modified: 17 Nov 2005 15:21
Reporter: a a Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:mysql-connector-java-5.0-nightly-2005102 OS:Linux (linux/solaris/macos)
Assigned to: Mark Matthews CPU Architecture:Any

[25 Oct 2005 0:41] a a
Description:
When XAConnections try to tidy themselves up, after being closed by the connection manager, ConnectionWrapper.close calls ConnectionWrapper.rollback without checking to see that it's XA.

20:28:53,924 IdleRemover WARN  [JBossManagedConnectionPool] Exception destroying ManagedConnection org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@d6535c[state=DESTROYED mc=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection@fac4a0 handles=0 lastUse=1130198783936 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@15998cb context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@3bd44c]
org.jboss.resource.JBossResourceException: SQLException; - nested throwable: (java.sql.SQLException: Can't call rollback() on an XAConnection)
        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkException(BaseWrapperManagedConnection.java:572)
        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.destroy(BaseWrapperManagedConnection.java:276)
        at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.destroy(XAManagedConnection.java:100)
        at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.doDestroy(InternalManagedConnectionPool.java:539)
        at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.removeTimedOut(InternalManagedConnectionPool.java:415)
        at org.jboss.resource.connectionmanager.IdleRemover$1.run(IdleRemover.java:70)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: Can't call rollback() on an XAConnection
        at com.mysql.jdbc.jdbc2.optional.ConnectionWrapper.rollback(ConnectionWrapper.java:737)
        at com.mysql.jdbc.jdbc2.optional.ConnectionWrapper.close(ConnectionWrapper.java:774)
        at com.mysql.jdbc.jdbc2.optional.ConnectionWrapper.close(ConnectionWrapper.java:419)
        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.destroy(BaseWrapperManagedConnection.java:272)

How to repeat:
Let an XA connection time out in pool.

Suggested fix:
*** ConnectionWrapper.java~     Sun Oct 23 00:06:22 2005
--- ConnectionWrapper.java      Mon Oct 24 20:36:42 2005
***************
*** 769,775 ****
                                return;
                        }
  
!                       if (this.mc.getRollbackOnPooledClose()
                                        && !this.getAutoCommit()) {
                                rollback();
                        }
--- 769,775 ----
                                return;
                        }
  
!                       if (!this.isForXa && this.mc.getRollbackOnPooledClose()
                                        && !this.getAutoCommit()) {
                                rollback();
                        }
[17 Nov 2005 15:21] Mark Matthews
Fix should be present in latest nightly builds of 5.0.0.