You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/09/23 09:33:46 UTC

[GitHub] [shardingsphere] local-li opened a new issue, #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

local-li opened a new issue, #21156:
URL: https://github.com/apache/shardingsphere/issues/21156

   我在org.apache.shardingsphere.transaction.xa.XAShardingTransactionManager中发现close方法。
   ```java
     @Override
       public void close() throws Exception {
           for (XATransactionDataSource each : cachedDataSources.values()) {
               each.close(); // 依次移除 Configuration.removeResource(res.getName());
           }
           cachedDataSources.clear();
           xaTransactionManager.close();  // 他会调用userTransactionService.shutdown(true);
       }
   ```
   However, call userTransactionService.shutdown(true); Is to shut down all resources in the Configuration. Isn't this unnecessary?
   
   I also don't quite understand why the transaction manager didn't expose the way to shut down a resource alone. In the method exposed by the userTransactionService, he only removed it from the resourceList_ and resources_, but did not call its close method, which resulted in the need to wait for jvm to collect system garbage. This resource will only be recycled.
   
   The problem that follows is that if I want to dynamically offline a logical library and its corresponding transaction manager on the proxy side, I cannot disconnect the proxy from mysql in time.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] local-li commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
local-li commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1260307386

   > The `Configuration.removeResource(resName)` method only removes the resource and does not close the resource,maybe you can refer to the logic of this method `com.atomikos.icatch.config.Configuration#removeAndCloseResources` 1.remove the resouce by resource name and return the resource object you want,`Configuration.removeResource ( res.getName () )`; 2.close the resource
   > 
   > ```java
   > private static void removeAndCloseResources(boolean force) {
   >   Collection<RecoverableResource> resources = Configuration.getResources();
   >   for (RecoverableResource res : resources) {
   > 		  Configuration.removeResource ( res.getName () );
   >           try {
   >               res.close ();
   >           } catch ( ResourceException re ) {
   >            // ...
   >           }
   >       }
   > }
   > ```
   
   
   
   Yes, I also noticed this method, but Configuration static classes are proxied by UserTransactionService.
   
   If I choose to cross it directly, is this a step-up in code design?
   
   At present, my solution is to manually call System.gc() after the program itself is removed. But I will do a stricter check before calling System.gc(). Do you think there will be other hidden problems in this way?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] FlyingZC commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1259073887

   I want to investigate this issue,please assign to me. @zhaojinchao95 


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] The XaDataSource-established Connection of the transaction manager was not properly closed. [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.
URL: https://github.com/apache/shardingsphere/issues/21156


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] FlyingZC commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1262270840

   Execute `System.gc()` is the bad way I think.Both `Configuration.removeResource(resName)` and `com.atomikos.icatch.config.Configuration#removeAndCloseResources` methods are not in the JTA specification.I think just remove the logic in the `org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosTransactionManagerProvider#removeRecoveryResource` and then let atomikos execute its own close logic.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] FlyingZC commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1260299447

   The `Configuration.removeResource(resName)` method only removes the resource and does not close the resource,maybe you can refer to the logic of this method
   `com.atomikos.icatch.config.Configuration#removeAndCloseResources`
   1.remove the resouce by resource name and return the resource object you want,`Configuration.removeResource ( res.getName () )`;
   2.close the resource
   ```java
   private static void removeAndCloseResources(boolean force) {
     Collection<RecoverableResource> resources = Configuration.getResources();
     for (RecoverableResource res : resources) {
   		  Configuration.removeResource ( res.getName () );
             try {
                 res.close ();
             } catch ( ResourceException re ) {
              // ...
             }
         }
   }
   ```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] The XaDataSource-established Connection of the transaction manager was not properly closed. [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-2212418819

   I don't think "library" is a concept related to ShardingSphere. Due to the high cost of understanding, please allow me to close this issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] FlyingZC commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1259219283

   @local-li I think you are right,atomikos will remove the resources and close the xa connections when we call the `close` method.If ss closes the connection by itself, atomikos will not execute the close logic.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1259082735

   @local-li Can you try the latest release version? Such as 5.2.0.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] local-li commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
local-li commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1259275394

   > @local-li I think you are right,atomikos will remove the resources and close the xa connections when we call the `close` method.If ss closes the connection by itself, atomikos will not execute the close logic.
   Can I only call Configuration.removeResource(res.getName()) myself to get the resource to close
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] local-li commented on issue #21156: The XaDataSource-established Connection of the transaction manager was not properly closed.

Posted by GitBox <gi...@apache.org>.
local-li commented on issue #21156:
URL: https://github.com/apache/shardingsphere/issues/21156#issuecomment-1259118474

   > 
   
   
   
   > @local-li Can you try the latest release version? Such as 5.2.0.
   
   Yes, I found the difference in 5.2.0, but only the following changes were made.
   
   1. Change the name to xaTransactionManagerProvider;
   2. Added an overloaded method public void begin(final int timeout)
   3. Judgment of legitimacy before xaTransactionManagerProvider.close()
   
   But such a change did not meet my expectations. What I want is that, in terms of the logical library dimension, the connection in the transaction manager of a logical library can be closed individually. Instead of XATransactionDataSource.close() just remove the resource from Configuration.removeResource(res.getName());.
   
   Of course, this part is not the source code of the framework itself. But there is such a need


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org