question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Atomikos XA transaction started when it is not configured in server.yaml

See original GitHub issue

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: WX20220706-152940@2x

In XAShardingSphereTransactionManager: Since AtomikosTransactionManagerProvider is the default impl of XATransactionManagerProvider, XATransactionManagerProviderFactory.getInstance(null) in XAShardingSphereTransactionManager.init return AtomikosTransactionManagerProvider instance. 图片

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
natehuangtingcommented, Nov 8, 2022

I will implement this function, other transaction types will not be loaded by default, if you need to load other transaction types, please configure in loadTypes

0reactions
FlyingZCcommented, Nov 8, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

[GitHub] [shardingsphere] sandynz commented on issue #18894 ...
... Atomikos XA transaction started when it is not configured in server.yaml ... TransactionRule should be initialized, because ss should provide the ...
Read more >
A Guide to Atomikos | Baeldung
Atomikos is a transaction library for Java applications. In this tutorial, we'll understand why and how to use Atomikos.
Read more >
Known Problems | Documentation - Atomikos
Below are some known issues and solutions. ActiveMQ error: "Transaction 'XID:...' has not been started"; ActiveMQ hangs when (re)connecting during broker ...
Read more >
Atomikos Transaction - Apache ShardingSphere
Apache ShardingSphere provides XA transactions, and the default XA transaction manager is Atomikos. Procedure. Configure the transaction type; Configure ...
Read more >
Distributed XA Transactions in a Spring Boot / Camel Application
I'll use Atomikos as a distributed transaction manager. What's the problem with testing? It's not easy to test such scenarios, as they always...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found