sandynz opened a new issue, #18894:
URL: https://github.com/apache/shardingsphere/issues/18894

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master branch, 0b41852bc93129f480989b33bda929fedc739199
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Proxy
   
   ### Expected behavior
   XA transaction won't be started.
   
   ### Actual behavior
   It started.
   
   ### Reason analyze (If you can)
   In GlobalRulesBuilder:
   <img width="1176" alt="WX20220706-152940@2x" 
src="https://user-images.githubusercontent.com/42492540/177501542-ca95718b-eb17-4b45-bcf0-fc986e12d8e0.png";>
   
   In XAShardingSphereTransactionManager:
   Since AtomikosTransactionManagerProvider is the default impl of 
XATransactionManagerProvider, 
`XATransactionManagerProviderFactory.getInstance(null)` in 
`XAShardingSphereTransactionManager.init` return 
AtomikosTransactionManagerProvider instance.
   <img width="1252" alt="图片" 
src="https://user-images.githubusercontent.com/42492540/177502052-f409bb37-0707-4a58-bc7b-3d055d1fdb99.png";>
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   `server.yaml`:
   ```
   mode:
     type: Cluster
     repository:
       type: ZooKeeper
       props:
         namespace: mysql
         server-lists: localhost:2181
         retryIntervalMilliseconds: 500
         timeToLiveSeconds: 60
         maxRetries: 3
         operationTimeoutMilliseconds: 500
     overwrite: false
   
   rules:
     - !AUTHORITY
       users:
         - root@%:root
         - sharding@:sharding
       provider:
         type: ALL_PERMITTED
   #  - !TRANSACTION
   #    defaultType: XA
   #    providerType: Atomikos
     - !SQL_PARSER
       sqlCommentParseEnabled: true
       sqlStatementCache:
         initialCapacity: 2000
         maximumSize: 65535
       parseTreeCache:
         initialCapacity: 128
         maximumSize: 1024
   ```
   
   Global rules in ZK after Proxy 3307 started:
   ```
   - !AUTHORITY
     provider:
       type: ALL_PERMITTED
     users:
     - root@%:root
     - sharding@%:sharding
   - !SQL_PARSER
     parseTreeCache:
       initialCapacity: 128
       maximumSize: 1024
     sqlCommentParseEnabled: true
     sqlStatementCache:
       initialCapacity: 2000
       maximumSize: 65535
   ```
   
   
   1, Start Proxy with 3307 port
   
   2, Start another Proxy with 3308 port
   
   The second one will start failed with exception:
   ```
   [ERROR] 2022-07-06 15:16:50.805 [main] c.a.persistence.imp.LogFileLock - The 
specified log seems to be in use already: xa_tx in ./logs/. Make sure that no 
other instance is running, or kill any pending process if needed.
   Exception in thread "main" com.atomikos.icatch.SysException: Error in init: 
The specified log seems to be in use already: xa_tx in ./logs/. Make sure that 
no other instance is running, or kill any pending process if needed.
        at 
com.atomikos.icatch.provider.imp.AssemblerImp.createRepository(AssemblerImp.java:200)
        at 
com.atomikos.icatch.provider.imp.AssemblerImp.assembleTransactionService(AssemblerImp.java:170)
        at 
com.atomikos.icatch.config.Configuration.assembleSystemComponents(Configuration.java:424)
        at com.atomikos.icatch.config.Configuration.init(Configuration.java:390)
        at 
com.atomikos.icatch.config.UserTransactionServiceImp.initialize(UserTransactionServiceImp.java:100)
        at 
com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:189)
        at 
org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosTransactionManagerProvider.init(AtomikosTransactionManagerProvider.java:46)
        at 
org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager.init(XAShardingSphereTransactionManager.java:55)
        at 
org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine.lambda$init$0(ShardingSphereTransactionManagerEngine.java:66)
        at java.util.Map.forEach(Map.java:630)
        at 
org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine.init(ShardingSphereTransactionManagerEngine.java:66)
        at 
org.apache.shardingsphere.transaction.rule.TransactionRule.createTransactionManagerEngine(TransactionRule.java:75)
        at 
org.apache.shardingsphere.transaction.rule.TransactionRule.createTransactionManagerEngines(TransactionRule.java:67)
        at 
org.apache.shardingsphere.transaction.rule.TransactionRule.<init>(TransactionRule.java:61)
        at 
org.apache.shardingsphere.transaction.rule.builder.TransactionRuleBuilder.build(TransactionRuleBuilder.java:36)
        at 
org.apache.shardingsphere.transaction.rule.builder.TransactionRuleBuilder.build(TransactionRuleBuilder.java:32)
        at 
org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder.buildRules(GlobalRulesBuilder.java:53)
        at 
org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder.buildMetaDataContexts(ClusterContextManagerBuilder.java:91)
        at 
org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder.build(ClusterContextManagerBuilder.java:69)
        at 
org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.createContextManager(BootstrapInitializer.java:66)
        at 
org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.init(BootstrapInitializer.java:55)
        at org.apache.shardingsphere.proxy.Bootstrap.main(Bootstrap.java:50)
   Caused by: com.atomikos.recovery.LogException: The specified log seems to be 
in use already: xa_tx in ./logs/. Make sure that no other instance is running, 
or kill any pending process if needed.
        at 
com.atomikos.persistence.imp.LogFileLock.acquireLock(LogFileLock.java:60)
        at 
com.atomikos.recovery.fs.FileSystemRepository.init(FileSystemRepository.java:53)
        at 
com.atomikos.icatch.provider.imp.AssemblerImp.createCoordinatorLogEntryRepository(AssemblerImp.java:248)
        at 
com.atomikos.icatch.provider.imp.AssemblerImp.createRepository(AssemblerImp.java:198)
        ... 21 more
   ```
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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