Skip to content

Commit

Permalink
Merge branch '2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Oct 17, 2023
2 parents a574f75 + 3baf2b4 commit 4f59905
Show file tree
Hide file tree
Showing 51 changed files with 3,479 additions and 20 deletions.
5 changes: 5 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@
<artifactId>fst</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver18</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The version is updated as follows:
- [[#5842](https://github.com/seata/seata/pull/5842)] adding metainfo to docker image
- [[#5902](https://github.com/seata/seata/pull/5902)] support IPv6
- [[#5907](https://github.com/seata/seata/pull/5907)] support polardb-x 2.0 in AT mode
- [[#5932](https://github.com/seata/seata/pull/5932)] support Dameng database

### bugfix:
- [[#5677](https://github.com/seata/seata/pull/5677)] fix saga mode serviceTask inputParams json autoType convert exception
Expand Down Expand Up @@ -132,6 +133,7 @@ The version is updated as follows:
- [[#5829](https://github.com/seata/seata/pull/5829)] fix codecov chart not display
- [[#5878](https://github.com/seata/seata/pull/5878)] optimize `httpcore` and `httpclient` dependencies
- [[#5917](https://github.com/seata/seata/pull/5917)] upgrade native-lib-loader version
- [[#5926](https://github.com/seata/seata/pull/5926)] optimize some scripts related to Apollo

### security:
- [[#5642](https://github.com/seata/seata/pull/5642)] add Hessian Serializer WhiteDenyList
Expand Down Expand Up @@ -186,6 +188,7 @@ Thanks to these contributors for their code commits. Please report an unintended
- [XQDD](https://github.com/XQDD)
- [Weelerer](https://github.com/Weelerer)
- [Ifdevil](https://github.com/Ifdevil)
- [iquanzhan](https://github.com/iquanzhan)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
Expand Down
4 changes: 3 additions & 1 deletion changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5842](https://github.com/seata/seata/pull/5842)] 构建docker 镜像时添加相关git信息,方便定位代码关系
- [[#5902](https://github.com/seata/seata/pull/5902)] 支持IPv6网络环境
- [[#5907](https://github.com/seata/seata/pull/5907)] 增加AT模式的PolarDB-X 2.0数据库支持
- [[#5932](https://github.com/seata/seata/pull/5932)] AT模式支持达梦数据库

### bugfix:
- [[#5677](https://github.com/seata/seata/pull/5677)] 修复saga模式下serviceTask入参autoType转化失败问题
Expand Down Expand Up @@ -132,7 +133,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5829](https://github.com/seata/seata/pull/5829)] 修正 `codecov chart` 不展示的问题
- [[#5878](https://github.com/seata/seata/pull/5878)] 优化 `httpcore``httpclient` 的依赖定义
- [[#5917](https://github.com/seata/seata/pull/5917)] 升级 native-lib-loader 版本

- [[#5926](https://github.com/seata/seata/pull/5926)] 优化一些与 Apollo 相关的脚本

### security:
- [[#5642](https://github.com/seata/seata/pull/5642)] 增加Hessian 序列化黑白名单
Expand Down Expand Up @@ -186,6 +187,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [XQDD](https://github.com/XQDD)
- [Weelerer](https://github.com/Weelerer)
- [Ifdevil](https://github.com/Ifdevil)
- [iquanzhan](https://github.com/iquanzhan)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。

Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/io/seata/common/util/PageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public static void checkParam(int pageNum, int pageSize) {
public static String pageSql(String sourceSql, String dbType, int pageNum, int pageSize) {
switch (dbType) {
case "mysql":
case "polardb-x":
case "h2":
case "postgresql":
case "oceanbase":
case "dm":
return LIMIT_TEMPLATE.replace(SOURCE_SQL_PLACE_HOLD, sourceSql)
.replace(LIMIT_PLACE_HOLD, String.valueOf(pageSize))
.replace(OFFSET_PLACE_HOLD, String.valueOf((pageNum - 1) * pageSize));
Expand All @@ -131,6 +131,7 @@ public static String countSql(String sourceSql, String dbType) {
case "h2":
case "oceanbase":
case "oracle":
case "dm":
return sourceSql.replaceAll("(?i)(?<=select)(.*)(?=from)", " count(1) ");
case "postgresql":
int lastIndexOfOrderBy = sourceSql.toLowerCase().lastIndexOf("order by");
Expand Down
3 changes: 2 additions & 1 deletion common/src/test/java/io/seata/common/util/PageUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public void testPageSql() {
" where rn between 1 and 5";

assertEquals(PageUtil.pageSql(sourceSql, "mysql", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "polardb-x", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "h2", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "postgresql", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "oceanbase", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "dm", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "oracle", 1, 5), oracleTargetSql);

assertThrows(NotSupportYetException.class, () -> PageUtil.pageSql(sourceSql, "xxx", 1, 5));
Expand All @@ -58,6 +58,7 @@ void testCountSql() {
assertEquals(PageUtil.countSql(sourceSql, "h2"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "postgresql"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "oceanbase"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "dm"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "oracle"), targetSql);

assertThrows(NotSupportYetException.class, () -> PageUtil.countSql(sourceSql, "xxx"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ private void readyApolloConfig() {
System.setProperty(PROP_APOLLO_SECRET, apolloAccesskeySecret);
}
}
if (!properties.containsKey(APOLLO_CLUSTER)) {
if (!properties.containsKey(PROP_APOLLO_CLUSTER)) {
String apolloCluster = FILE_CONFIG.getConfig(getApolloCluster());
if (StringUtils.isNotBlank(apolloCluster)) {
System.setProperty(PROP_APOLLO_CLUSTER, apolloCluster);
}
}
if (!properties.containsKey(APOLLO_CONFIG_SERVICE)) {
if (!properties.containsKey(PROP_APOLLO_CONFIG_SERVICE)) {
String apolloConfigService = FILE_CONFIG.getConfig(getApolloConfigService());
if (StringUtils.isNotBlank(apolloConfigService)) {
System.setProperty(PROP_APOLLO_CONFIG_SERVICE, apolloConfigService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DistributedLockSqlFactory {
/**
* get the lock store sql
*
* @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase, it's useless now, but maybe useful later
* @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm, it's useless now, but maybe useful later
* @return lock store sql
*/
public static DistributedLockSql getDistributedLogStoreSql(String dbType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.store.db.sql.lock;

import io.seata.common.loader.LoadLevel;

/**
* the database lock store DaMeng sql
*
* @author wang.liang
* @since 1.8.0
*/
@LoadLevel(name = "dm")
public class DmLockStoreSql extends MysqlLockStoreSql {
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LockStoreSqlFactory {
/**
* get the lock store sql
*
* @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase
* @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm
* @return lock store sql
*/
public static LockStoreSql getLogStoreSql(String dbType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.core.store.db.sql.log;

import io.seata.common.loader.LoadLevel;

/**
* Database log store DaMeng sql
*
* @author wang.liang
* @since 1.8.0
*/
@LoadLevel(name = "dm")
public class DmLogStoreSqls extends MysqlLogStoreSqls {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ io.seata.core.store.db.sql.lock.PostgresqlLockStoreSql
io.seata.core.store.db.sql.lock.H2LockStoreSql
io.seata.core.store.db.sql.lock.SqlServerLockStoreSql
io.seata.core.store.db.sql.lock.MariadbLockStoreSql
io.seata.core.store.db.sql.lock.PolarDBXLockStoreSql
io.seata.core.store.db.sql.lock.PolarDBXLockStoreSql
io.seata.core.store.db.sql.lock.DmLockStoreSql
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ io.seata.core.store.db.sql.log.OceanbaseLogStoreSqls
io.seata.core.store.db.sql.log.H2LogStoreSqls
io.seata.core.store.db.sql.log.SqlServerLogStoreSqls
io.seata.core.store.db.sql.log.MariadbLogStoreSqls
io.seata.core.store.db.sql.log.PolarDBXLogStoreSqls
io.seata.core.store.db.sql.log.PolarDBXLogStoreSqls
io.seata.core.store.db.sql.log.DmLogStoreSqls
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class LockStoreSqlFactoryTest {

private static LockStoreSql OCEANBASE_LOCK_STORE = LockStoreSqlFactory.getLogStoreSql("oceanbase");

private static LockStoreSql DM_LOCK_STORE = LockStoreSqlFactory.getLogStoreSql("dm");

private static String GLOBAL_TABLE = "global_table";

private static String BRANCH_TABLE = "branch_table";
Expand Down Expand Up @@ -331,4 +333,50 @@ public void oceanbaseLockTest() {
sql = OCEANBASE_LOCK_STORE.getCheckLockableSql(BRANCH_TABLE, 3);
Assertions.assertEquals(EXPECT_CHECK_BRANCH_LOCKABLE_SQL,sql);
}

@Test
public void dmLockTest() {
String sql;
// Get insert lock sql string.
sql = DM_LOCK_STORE.getInsertLockSQL(GLOBAL_TABLE);
Assertions.assertNotNull(sql);
sql = DM_LOCK_STORE.getInsertLockSQL(BRANCH_TABLE);
Assertions.assertNotNull(sql);

// Get delete lock sql string.
sql = DM_LOCK_STORE.getDeleteLockSql(GLOBAL_TABLE);
Assertions.assertNotNull(sql);
sql = DM_LOCK_STORE.getDeleteLockSql(BRANCH_TABLE);
Assertions.assertNotNull(sql);

// Get batch delete lock sql string.
sql = DM_LOCK_STORE.getBatchDeleteLockSql(GLOBAL_TABLE, 3);
Assertions.assertEquals(EXPECT_BATCH_GLOBAL_DELETE_LOCK_SQL,sql);
sql = DM_LOCK_STORE.getBatchDeleteLockSql(BRANCH_TABLE, 3);
Assertions.assertEquals(EXPECT_BATCH_BRANCH_DELETE_LOCK_SQL,sql);

// Get batch delete lock sql string.
sql = DM_LOCK_STORE.getBatchDeleteLockSqlByBranchId(GLOBAL_TABLE);
Assertions.assertNotNull(sql);
sql = DM_LOCK_STORE.getBatchDeleteLockSqlByBranchId(BRANCH_TABLE);
Assertions.assertNotNull(sql);

// Get batch delete lock sql string.
sql = DM_LOCK_STORE.getBatchDeleteLockSqlByXid(GLOBAL_TABLE);
Assertions.assertEquals(EXPECT_BATCH_GLOBAL_DELETE_LOCK_BY_BRANCHS_SQL,sql);
sql = DM_LOCK_STORE.getBatchDeleteLockSqlByXid(BRANCH_TABLE);
Assertions.assertEquals(EXPECT_BATCH_BRANCH_DELETE_LOCK_BY_BRANCHS_SQL,sql);

// Get query lock sql string.
sql = DM_LOCK_STORE.getQueryLockSql(GLOBAL_TABLE);
Assertions.assertNotNull(sql);
sql = DM_LOCK_STORE.getQueryLockSql(BRANCH_TABLE);
Assertions.assertNotNull(sql);

// Get check lock sql string.
sql = DM_LOCK_STORE.getCheckLockableSql(GLOBAL_TABLE, 3);
Assertions.assertEquals(EXPECT_CHECK_GLOBAL_LOCKABLE_SQL,sql);
sql = DM_LOCK_STORE.getCheckLockableSql(BRANCH_TABLE, 3);
Assertions.assertEquals(EXPECT_CHECK_BRANCH_LOCKABLE_SQL,sql);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class LogStoreSqlsFactoryTest {

private static LogStoreSqls oceanbase = LogStoreSqlsFactory.getLogStoreSqls("oceanbase");

private static LogStoreSqls dmLog = LogStoreSqlsFactory.getLogStoreSqls("dm");

private static String globalTable = "global_table";

private static String branchTable = "branch_table";
Expand Down Expand Up @@ -211,4 +213,38 @@ public void oceanbaseLogTest() {
sql = oceanbase.getQueryBranchMax(branchTable);
Assertions.assertNotNull(sql);
}

@Test
public void dmLogTest() {
String sql = dmLog.getInsertGlobalTransactionSQL(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getUpdateGlobalTransactionStatusSQL(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getDeleteGlobalTransactionSQL(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryGlobalTransactionSQL(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryGlobalTransactionSQLByTransactionId(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryGlobalTransactionSQLByStatus(globalTable, "1");
Assertions.assertNotNull(sql);
sql = dmLog.getQueryGlobalTransactionForRecoverySQL(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getInsertBranchTransactionSQL(branchTable);
Assertions.assertNotNull(sql);
sql = dmLog.getUpdateBranchTransactionStatusSQL(branchTable);
Assertions.assertNotNull(sql);
sql = dmLog.getDeleteBranchTransactionByBranchIdSQL(branchTable);
Assertions.assertNotNull(sql);
sql = dmLog.getDeleteBranchTransactionByXId(branchTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryBranchTransaction(branchTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryBranchTransaction(branchTable, "1");
Assertions.assertNotNull(sql);
sql = dmLog.getQueryGlobalMax(globalTable);
Assertions.assertNotNull(sql);
sql = dmLog.getQueryBranchMax(branchTable);
Assertions.assertNotNull(sql);
}
}
6 changes: 6 additions & 0 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<!-- db -->
<mysql.version>5.1.42</mysql.version>
<ojdbc.version>19.3.0.0</ojdbc.version>
<dm.version>8.1.2.192</dm.version>
<postgresql.version>42.3.3</postgresql.version>
<h2.version>1.4.181</h2.version>
<mariadb.version>2.7.2</mariadb.version>
Expand Down Expand Up @@ -214,6 +215,11 @@
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver18</artifactId>
<version>${dm.version}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ private void initResourceId() {
initMysqlResourceId();
} else if (JdbcConstants.SQLSERVER.equals(dbType)) {
initSqlServerResourceId();
} else if (JdbcConstants.DM.equals(dbType)) {
initDMResourceId();
} else {
initDefaultResourceId();
}
Expand Down Expand Up @@ -228,6 +230,36 @@ private void initMysqlResourceId() {
}
}

private void initDMResourceId() {
LOGGER.warn("support for the dameng database is currently an experimental feature ");
if (jdbcUrl.contains("?")) {
StringBuilder jdbcUrlBuilder = new StringBuilder();
jdbcUrlBuilder.append(jdbcUrl, 0, jdbcUrl.indexOf('?'));

StringBuilder paramsBuilder = new StringBuilder();
String paramUrl = jdbcUrl.substring(jdbcUrl.indexOf('?') + 1);
String[] urlParams = paramUrl.split("&");
for (String urlParam : urlParams) {
if (urlParam.contains("schema")) {
// remove the '"'
if (urlParam.contains("\"")) {
urlParam = urlParam.replaceAll("\"", "");
}
paramsBuilder.append(urlParam);
break;
}
}

if (paramsBuilder.length() > 0) {
jdbcUrlBuilder.append("?");
jdbcUrlBuilder.append(paramsBuilder);
}
resourceId = jdbcUrlBuilder.toString();
} else {
resourceId = jdbcUrl;
}
}

/**
* prevent pg sql url like
* jdbc:postgresql://127.0.0.1:5432/seata?currentSchema=public
Expand Down
Loading

0 comments on commit 4f59905

Please sign in to comment.