Issue 1:
Question

For English only, other languages will not accept.

Before asking a question, make sure you have:

Googled your question.

Searched open and closed GitHub issues.

Read documentation: ShardingSphere Doc.

Please pay attention on issues you submitted, because we maybe need more details.

If no response anymore and we cannot reproduce it on current information, we will close it.

In the current https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/distsql/syntax/rdl/resource-definition/, which requires Before adding resources, please confirm that a distributed database has been created, and execute the use command to successfully select a database;. This means to people that when starting ShardingSphere Proxy, not only does the server.yaml need to exist, but at least one config-*.yaml needs to be created to define at least one data source.

When using the Docker Image of https://github.com/apache/shardingsphere/pkgs/container/shardingsphere-proxy/44714726?tag=f4080b1b3ddcaa9eb15e87e50a6fb0d2fe2baa7f, if the RDL is directly executed, the following exception will appear on the server.

[ERROR] 2022-10-10 04:20:53.273 [Connection-1-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: Object 'proc' not found within 'mysql'
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at jdk.internal.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:932)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917)
at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5362)
at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:138)
at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:188)
at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1107)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3381)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1078)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3360)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3697)
at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:64)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:248)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:759)
at org.apache.shardingsphere.sqlfederation.advanced.AdvancedSQLFederationExecutor.executeQuery(AdvancedSQLFederationExecutor.java:110)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.doExecuteFederation(JDBCDatabaseCommunicationEngine.java:163)
at org.apache.shardingsphere.sqlfederation.advanced.AdvancedSQLFederationExecutor.execute(AdvancedSQLFederationExecutor.java:141)
at org.apache.shardingsphere.sqlfederation.optimizer.SQLOptimizeEngine.optimize(SQLOptimizeEngine.java:50)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:592)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1053)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:121)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:111)
at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:94)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

I'm not quite sure if this is an expected behavior.

Issue 2:
Bug Report

Which version of ShardingSphere did you use?

master branch, 0b41852

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:

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