sandynz commented on issue #13434:
URL: 
https://github.com/apache/shardingsphere/issues/13434#issuecomment-961748150


   > I found out through debugging that the lower version of Atomikos may cause 
connection leaks. when i replace another version of Atomikos 5.0.8 the 
connection leaks did not happened.
   
   @ccw55ccw Thanks for sharing.
   
   I tested with version `4.0.6` and `5.0.8`, that's true. I found the code 
difference of these two versions.
   
   In XATransactionalResource.setRecoveryService (version 4.0.6)
   ```
        public void setRecoveryService ( RecoveryService recoveryService )
               throws ResourceException
       {
           if ( recoveryService != null ) {
               if ( LOGGER.isTraceEnabled() ) LOGGER.logTrace ( "Installing 
recovery service on resource "
                       + getName () );
               this.branchIdentifier=recoveryService.getName();
               recover();
           }
       }
   ```
   
   In XATransactionalResource.setRecoveryService (version 5.0.8)
   ```
        public void setRecoveryService ( RecoveryService recoveryService )
               throws ResourceException
       {
           if ( recoveryService != null ) {
               if ( LOGGER.isTraceEnabled() ) LOGGER.logTrace ( "Installing 
recovery service on resource "
                       + getName () );
               this.branchIdentifier=recoveryService.getName();
           }
       }
   ```
   Invocation of `recover()` is the difference.
   
   Part of stack trace of new connection created in version 4.0.6:
   ```
   "Connection-1-ThreadExecutor@6093" prio=10 tid=0x34 nid=NA runnable
     java.lang.Thread.State: RUNNABLE
          at 
com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:124)
          at 
com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:107)
          at 
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.getXAConnection(MysqlXADataSource.java:46)
          at 
com.atomikos.datasource.xa.jdbc.JdbcTransactionalResource.createXAConnection(JdbcTransactionalResource.java:167)
          at 
com.atomikos.datasource.xa.jdbc.JdbcTransactionalResource.refreshXAConnection(JdbcTransactionalResource.java:100)
          - locked <0x2b98> (a 
org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosXARecoverableResource)
          at 
com.atomikos.datasource.xa.XATransactionalResource.refreshXAResource(XATransactionalResource.java:459)
          at 
com.atomikos.datasource.xa.XATransactionalResource.getXAResource(XATransactionalResource.java:315)
          at 
com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:449)
          at 
com.atomikos.datasource.xa.XATransactionalResource.setRecoveryService(XATransactionalResource.java:416)
          at 
com.atomikos.icatch.config.Configuration.addResource(Configuration.java:249)
          - locked <0x1d15> (a java.lang.Class)
          at 
com.atomikos.icatch.config.UserTransactionServiceImp.registerResource(UserTransactionServiceImp.java:124)
          at 
org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosTransactionManagerProvider.registerRecoveryResource(AtomikosTransactionManagerProvider.java:51)
          at 
org.apache.shardingsphere.transaction.xa.jta.datasource.XATransactionDataSource.<init>(XATransactionDataSource.java:65)
          at 
org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager.newXATransactionDataSource(XAShardingSphereTransactionManager.java:62)
   ```
   
   I had a short look at Atomikos [Release 
Notes](https://www.atomikos.com/Main/ReleaseNotes) and [TransactionsEssentials 
5.0](https://www.atomikos.com/Blog/TransactionsEssentials5dot0), it need more 
investigation of upgrading atomikos version.
   
   Upgrade atomikos may be the easiest way, I'm considering other ways too.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to