Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for unjudged Seata AT transactions caused by #30462 #30474

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建

使用者需要主动使用 GraalVM Reachability Metadata 中央仓库。
如下配置可供参考,以配置项目额外的 Maven Profiles,以 GraalVM Native Build Tools 的文档为准。
由于 Gradle 8.6 的限制,用户需要通过 Maven 依赖的形式引入 Metadata Repository 的 JSON 文件。
参考 https://github.com/graalvm/native-build-tools/issues/572 。

```xml
<project>
Expand All @@ -37,7 +39,7 @@ ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.0</version>
<version>0.10.1</version>
<extensions>true</extensions>
<configuration>
<buildArgs>
Expand Down Expand Up @@ -73,12 +75,12 @@ ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建

```groovy
plugins {
id 'org.graalvm.buildtools.native' version '0.10.0'
id 'org.graalvm.buildtools.native' version '0.10.1'
}

dependencies {
implementation 'org.apache.shardingsphere:shardingsphere-jdbc:${shardingsphere.version}'
implementation(group: 'org.graalvm.buildtools', name: 'graalvm-reachability-metadata', version: '0.10.0', classifier: 'repository', ext: 'zip')
implementation(group: 'org.graalvm.buildtools', name: 'graalvm-reachability-metadata', version: '0.10.1', classifier: 'repository', ext: 'zip')
}

graalvmNative {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and the documentation of GraalVM Native Build Tools shall prevail.
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.0</version>
<version>0.10.1</version>
<extensions>true</extensions>
<configuration>
<buildArgs>
Expand Down Expand Up @@ -73,15 +73,18 @@ and the documentation of GraalVM Native Build Tools shall prevail.
Users need to actively use the GraalVM Reachability Metadata central repository.
The following configuration is for reference to configure additional Gradle Tasks for the project,
and the documentation of GraalVM Native Build Tools shall prevail.
Due to the limitations of Gradle 8.6,
users need to introduce the JSON file of Metadata Repository through Maven dependency.
Reference https://github.com/graalvm/native-build-tools/issues/572 .

```groovy
plugins {
id 'org.graalvm.buildtools.native' version '0.10.0'
id 'org.graalvm.buildtools.native' version '0.10.1'
}

dependencies {
implementation 'org.apache.shardingsphere:shardingsphere-jdbc:${shardingsphere.version}'
implementation(group: 'org.graalvm.buildtools', name: 'graalvm-reachability-metadata', version: '0.10.0', classifier: 'repository', ext: 'zip')
implementation(group: 'org.graalvm.buildtools', name: 'graalvm-reachability-metadata', version: '0.10.1', classifier: 'repository', ext: 'zip')
}

graalvmNative {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public <T> List<T> execute(final ExecutionGroupContext<JDBCExecutionUnit> execut
public <T> List<T> execute(final ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext,
final JDBCExecutorCallback<T> firstCallback, final JDBCExecutorCallback<T> callback) throws SQLException {
try {
return executorEngine.execute(executionGroupContext, firstCallback, callback, connectionContext.getTransactionContext().isInXATransaction());
return executorEngine.execute(executionGroupContext, firstCallback, callback, connectionContext.getTransactionContext().isInDistributedTransaction());
} catch (final SQLException ex) {
SQLExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name":"org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.broadcast.yaml.swapper.NewYamlBroadcastRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.broadcast.yaml.swapper.YamlBroadcastDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getTables","parameterTypes":[] }]
Expand Down Expand Up @@ -125,7 +125,7 @@
"name":"org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfigurationCustomizer"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.encrypt.yaml.swapper.NewYamlEncryptRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.encrypt.yaml.swapper.YamlEncryptDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getColumns","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }]
Expand All @@ -150,7 +150,7 @@
"name":"org.apache.shardingsphere.globalclock.core.yaml.config.YamlGlobalClockRuleConfiguration"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.encrypt.yaml.swapper.NewYamlEncryptRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.encrypt.yaml.swapper.YamlEncryptDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProps","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
Expand All @@ -163,19 +163,19 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setProps","parameterTypes":["java.util.Properties"] }, {"name":"setType","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mask.yaml.swapper.NewYamlMaskRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.mask.yaml.swapper.YamlMaskDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProps","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.NewYamlShadowRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.YamlShadowDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProps","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.NewYamlShardingRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.YamlShardingDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProps","parameterTypes":[] }, {"name":"getType","parameterTypes":[] }]
Expand Down Expand Up @@ -466,7 +466,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setColumns","parameterTypes":["java.util.Map"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mask.yaml.swapper.NewYamlMaskRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.mask.yaml.swapper.YamlMaskDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getColumns","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }]
Expand Down Expand Up @@ -614,7 +614,7 @@
"name":"org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.parser.yaml.swapper.NewYamlSQLParserRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.parser.yaml.swapper.YamlSQLParserDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getParseTreeCache","parameterTypes":[] }, {"name":"getSqlStatementCache","parameterTypes":[] }]
Expand Down Expand Up @@ -654,7 +654,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setReadDataSourceNames","parameterTypes":["java.util.List"] }, {"name":"setWriteDataSourceName","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.readwritesplitting.yaml.swapper.NewYamlReadwriteSplittingRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.readwritesplitting.yaml.swapper.YamlReadwriteSplittingDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getLoadBalancerName","parameterTypes":[] }, {"name":"getReadDataSourceNames","parameterTypes":[] }, {"name":"getTransactionalReadQueryStrategy","parameterTypes":[] }, {"name":"getWriteDataSourceName","parameterTypes":[] }]
Expand Down Expand Up @@ -709,7 +709,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setProductionDataSourceName","parameterTypes":["java.lang.String"] }, {"name":"setShadowDataSourceName","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.NewYamlShadowRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.YamlShadowDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getProductionDataSourceName","parameterTypes":[] }, {"name":"getShadowDataSourceName","parameterTypes":[] }]
Expand All @@ -730,7 +730,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setDataSourceNames","parameterTypes":["java.util.Collection"] }, {"name":"setShadowAlgorithmNames","parameterTypes":["java.util.Collection"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.NewYamlShadowRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.shadow.yaml.swapper.YamlShadowDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getDataSourceNames","parameterTypes":[] }, {"name":"getShadowAlgorithmNames","parameterTypes":[] }]
Expand Down Expand Up @@ -825,7 +825,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setActualDataNodes","parameterTypes":["java.lang.String"] }, {"name":"setKeyGenerateStrategy","parameterTypes":["org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.NewYamlShardingRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.YamlShardingDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getActualDataNodes","parameterTypes":[] }, {"name":"getAuditStrategy","parameterTypes":[] }, {"name":"getDatabaseStrategy","parameterTypes":[] }, {"name":"getKeyGenerateStrategy","parameterTypes":[] }, {"name":"getLogicTable","parameterTypes":[] }, {"name":"getTableStrategy","parameterTypes":[] }]
Expand Down Expand Up @@ -866,7 +866,7 @@
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setStandard","parameterTypes":["org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration"] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.NewYamlShardingRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.yaml.swapper.YamlShardingDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getComplex","parameterTypes":[] }, {"name":"getHint","parameterTypes":[] }, {"name":"getNone","parameterTypes":[] }, {"name":"getStandard","parameterTypes":[] }]
Expand Down Expand Up @@ -931,7 +931,7 @@
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.single.yaml.config.swapper.NewYamlSingleRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.single.yaml.config.swapper.YamlSingleDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getDefaultDataSource","parameterTypes":[] }, {"name":"getTables","parameterTypes":[] }]
Expand Down Expand Up @@ -1156,6 +1156,10 @@
"condition":{"typeReachable":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationPlannerUtils"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sqlfederation.rule.SQLFederationMetaDataHeldRule"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
Expand Down Expand Up @@ -1228,7 +1232,7 @@
"name":"org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.yaml.swapper.NewYamlTransactionRuleConfigurationSwapper"},
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.yaml.swapper.YamlTransactionDataNodeRuleConfigurationSwapper"},
"name":"org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration",
"allDeclaredFields":true,
"methods":[{"name":"getDefaultType","parameterTypes":[] }, {"name":"getProps","parameterTypes":[] }, {"name":"getProviderType","parameterTypes":[] }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader"},
"pattern":".*META-INF/services/org\\.apache\\.shardingsphere\\..+"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilder"},
"condition":{"typeReachable":"org.apache.shardingsphere.infra.metadata.database.schema.manager.SystemSchemaManager"},
"pattern":".*schema/.+\\.yaml$"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"},
"pattern":".*sql/.+\\.xml$"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.state.datasource.DataSourceStateManager"},
"pattern":"\\QMETA-INF/services/java.sql.Driver\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.directory.ClasspathResourceDirectoryReader"},
"pattern":"\\Qschema\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.mode.repository.standalone.jdbc.sql.JDBCRepositorySQLLoader"},
"pattern":"\\Qsql\\E"
}, {
"condition":{"typeReachable":"org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosTransactionManagerProvider"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void beginTransaction(final String transactionType) {
}

/**
* Judge is in XA transaction or not.
* Judge is in distributed transaction or not.
*
* @return in XA transaction or not
* @return in distributed transaction or not
*/
public boolean isInXATransaction() {
return inTransaction && "XA".equals(transactionType);
public boolean isInDistributedTransaction() {
return inTransaction && ("XA".equals(transactionType) || "BASE".equals(transactionType));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
<docker-compose-maven-plugin.version>4.0.0</docker-compose-maven-plugin.version>
<os-maven-plugin.version>1.6.2</os-maven-plugin.version>
<native-maven-plugin.version>0.10.0</native-maven-plugin.version>
<native-maven-plugin.version>0.10.1</native-maven-plugin.version>

<!-- Compile plugin versions -->
<templating-maven-plugin.version>1.0.0</templating-maven-plugin.version>
Expand Down
1 change: 0 additions & 1 deletion test/native/native-image-filter/extra-filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{"excludeClasses": "com.sun.org.apache.xerces.internal.jaxp.**"},
{"excludeClasses": "java.**"},
{"includeClasses": "java.lang.Boolean"},
{"includeClasses": "java.lang.Thread"},
{"includeClasses": "java.util.Properties"},
{"excludeClasses": "javax.security.auth.x500.**"},
{"excludeClasses": "javax.smartcardio.**"},
Expand Down
2 changes: 2 additions & 0 deletions test/native/native-image-filter/user-code-filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
{"excludeClasses": "**"},
{"includeClasses": "org.apache.shardingsphere.**"},
{"excludeClasses": "org.apache.shardingsphere.test.natived.**"}
],
"regexRules": [
]
}