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

bugfix: fix undo_log id repeat #4985

Merged
merged 36 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e9e7255
release 0.5.1
slievrly Apr 30, 2019
f017c6b
release 0.5.2
slievrly May 17, 2019
7ca3332
Release 0.6.0 (#1106)
zhangthen May 24, 2019
dc088cb
Revert "Release 0.6.0 (#1106)" (#1107)
slievrly May 27, 2019
da96029
re-merging 0.6.0
slievrly May 27, 2019
ca567ef
Release 0.6.1
zhangthen May 31, 2019
1b90f93
release 0.7.0
slievrly Jul 12, 2019
39e4d89
release 0.7.1
slievrly Jul 15, 2019
0945681
release 0.8.0
slievrly Aug 16, 2019
9ffa290
release 0.8.1
slievrly Sep 18, 2019
a174ed5
release 0.9.0
slievrly Oct 16, 2019
5bdbc44
[release] release 1.0.0
slievrly Dec 20, 2019
f990a57
release: release 1.1.0
slievrly Feb 19, 2020
04d0568
Merge pull request #2582 from seata/1.2.0
slievrly Apr 21, 2020
2e2a424
release: release 1.3.0
slievrly Jul 15, 2020
f270a2d
Merge pull request #3252 from seata/1.4.0
slievrly Nov 2, 2020
ce86bdc
change version to 1.4.1
slievrly Dec 9, 2020
fcc74e7
Merge remote-tracking branch 'upstream/develop' into 1.4.1
slievrly Dec 9, 2020
9569bed
release: release 1.4.1
slievrly Dec 10, 2020
f8359f0
[release]: release for 1.4.1
slievrly Feb 8, 2021
8bd92a5
Merge branch 'master' into 1.4.2
slievrly Apr 23, 2021
5ddfbc1
[release]: release for 1.4.2
slievrly Apr 25, 2021
1c22e62
optimize: some tiny fixes in release 1.5.0 (#4611)
slievrly May 15, 2022
be9c3eb
Merge branch 'master' into 1.5.0
slievrly May 15, 2022
3d26425
doc: update change.md (#4612) (#4613)
slievrly May 15, 2022
ede95ef
Merge pull request #4610 from seata/1.5.0
slievrly May 17, 2022
46d75f3
optimize: fix conflicts
slievrly Jul 12, 2022
c95d49f
Merge pull request #4771 from seata/1.5.2
slievrly Jul 12, 2022
d5f30f8
bugfix: fix undo_log `id` repeat
whxxxxx Oct 10, 2022
699a1dd
Merge branch 'develop' into hotfix_field_distinct
funky-eyes Oct 10, 2022
51a965a
bugfix: fix undo_log `id` repeat
whxxxxx Oct 10, 2022
e9172fd
bugfix: Use methods that in ColumnUtils
whxxxxx Oct 11, 2022
025955b
bugfix: modify ColumnUtils,KeywordChecker,KeywordCheckerFactory route
whxxxxx Oct 11, 2022
79cb474
bugfix: insert test case
whxxxxx Oct 12, 2022
ac308e2
bugfix: insert test case
whxxxxx Oct 12, 2022
0952519
Merge branch 'develop' into hotfix_field_distinct
slievrly Oct 12, 2022
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
3 changes: 3 additions & 0 deletions changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Add changes here for all PR submitted to the develop branch.
- [[#4962](https://github.com/seata/seata/pull/4962)] optimize build and fix the base image
- [[#4974](https://github.com/seata/seata/pull/4974)] optimize cancel the limit on the number of globalStatus queries in Redis mode
- [[#4981](https://github.com/seata/seata/pull/4981)] optimize tcc fence record not exists errMessage
- [[#4985](https://github.com/seata/seata/pull/4985)] fix undo_log id repeat


### test:
- [[#4794](https://github.com/seata/seata/pull/4794)] try to fix the test `DataSourceProxyTest.getResourceIdTest()`
Expand All @@ -70,5 +72,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [jsbxyyx](https://github.com/jsbxyyx)
- [tuwenlin](https://github.com/tuwenlin)
- [CrazyLionLi](https://github.com/JavaLionLi)
- [whxxxxx](https://github.com/whxxxxx)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
2 changes: 2 additions & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [[#4928](https://github.com/seata/seata/pull/4928)] 修复 rpcContext.getClientRMHolderMap NPE 问题
- [[#4953](https://github.com/seata/seata/pull/4953)] 修复InsertOnDuplicateUpdate可绕过修改主键的问题
- [[#4978](https://github.com/seata/seata/pull/4978)] 修复 kryo 支持循环依赖
- [[#4985](https://github.com/seata/seata/pull/4985)] 修复 undo_log id重复的问题

### optimize:
- [[#4774](https://github.com/seata/seata/pull/4774)] 优化 seataio/seata-server 镜像中的 mysql8 依赖
Expand Down Expand Up @@ -70,5 +71,6 @@
- [jsbxyyx](https://github.com/jsbxyyx)
- [tuwenlin](https://github.com/tuwenlin)
- [CrazyLionLi](https://github.com/JavaLionLi)
- [whxxxxx](https://github.com/whxxxxx)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ protected TableRecords buildTableRecords(Map<String, List<Object>> pkValuesMap)
List<String> insertColumns = recognizer.getInsertColumns();
if (ONLY_CARE_UPDATE_COLUMNS && CollectionUtils.isNotEmpty(insertColumns)) {
Set<String> columns = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
columns.addAll(recognizer.getInsertColumns());
columns.addAll(recognizer.getInsertColumnsIsSimplified());
columns.addAll(pkColumnNameList);
for (String columnName : columns) {
selectSQLJoin.add(columnName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected TableRecords beforeImage() throws SQLException {
throw new NotSupportYetException("Multi update SQL with orderBy condition is not support yet !");
}

List<String> updateColumns = sqlUpdateRecognizer.getUpdateColumns();
List<String> updateColumns = sqlUpdateRecognizer.getUpdateColumnsIsSimplified();
updateColumnsSet.addAll(updateColumns);
if (noWhereCondition) {
continue;
Expand Down Expand Up @@ -155,7 +155,7 @@ private String buildAfterImageSQL(TableMeta tableMeta, TableRecords beforeImage)
for (SQLRecognizer recognizer : sqlRecognizers) {
sqlRecognizer = recognizer;
SQLUpdateRecognizer sqlUpdateRecognizer = (SQLUpdateRecognizer) sqlRecognizer;
updateColumnsSet.addAll(sqlUpdateRecognizer.getUpdateColumns());
updateColumnsSet.addAll(sqlUpdateRecognizer.getUpdateColumnsIsSimplified());
}
StringBuilder prefix = new StringBuilder("SELECT ");
String suffix = " FROM " + getFromTableInSQL() + " WHERE " + SqlGenerateUtils.buildWhereConditionByPKs(tableMeta.getPrimaryKeyOnlyName(), beforeImage.pkRows().size(), getDbType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected TableRecords beforeImage() throws SQLException {

private String buildBeforeImageSQL(TableMeta tableMeta, ArrayList<List<Object>> paramAppenderList) {
SQLUpdateRecognizer recognizer = (SQLUpdateRecognizer) sqlRecognizer;
List<String> updateColumns = recognizer.getUpdateColumns();
List<String> updateColumns = recognizer.getUpdateColumnsIsSimplified();
StringBuilder prefix = new StringBuilder("SELECT ");
StringBuilder suffix = new StringBuilder(" FROM ").append(getFromTableInSQL());
String whereCondition = buildWhereCondition(recognizer, paramAppenderList);
Expand Down Expand Up @@ -136,7 +136,7 @@ private String buildAfterImageSQL(TableMeta tableMeta, TableRecords beforeImage)
StringJoiner selectSQLJoiner = new StringJoiner(", ", prefix.toString(), suffix);
if (ONLY_CARE_UPDATE_COLUMNS) {
SQLUpdateRecognizer recognizer = (SQLUpdateRecognizer) sqlRecognizer;
List<String> updateColumns = recognizer.getUpdateColumns();
List<String> updateColumns = recognizer.getUpdateColumnsIsSimplified();
if (!containsPK(updateColumns)) {
selectSQLJoiner.add(getColumnNamesInSQL(tableMeta.getEscapePkNameList(getDbType())));
}
Expand Down
6 changes: 6 additions & 0 deletions sqlparser/seata-sqlparser-antlr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-rm-datasource</artifactId>
funky-eyes marked this conversation as resolved.
Show resolved Hide resolved
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/
package io.seata.sqlparser.antlr.mysql;

import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.SQLInsertRecognizer;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.antlr.mysql.parser.MySqlLexer;
import io.seata.sqlparser.antlr.mysql.parser.MySqlParser;
import io.seata.sqlparser.antlr.mysql.stream.ANTLRNoCaseStringStream;
import io.seata.sqlparser.antlr.mysql.visit.InsertStatementSqlVisitor;
import io.seata.sqlparser.util.JdbcConstants;
import org.antlr.v4.runtime.CommonTokenStream;

import java.util.ArrayList;
Expand Down Expand Up @@ -105,4 +107,10 @@ public List<String> getInsertParamsValue() {
public List<String> getDuplicateKeyUpdate() {
return null;
}

@Override
public List<String> getInsertColumnsIsSimplified() {
List<String> insertColumns = getInsertColumns();
return ColumnUtils.delEscape(insertColumns, JdbcConstants.MYSQL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package io.seata.sqlparser.antlr.mysql;

import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.SQLUpdateRecognizer;
import io.seata.sqlparser.antlr.mysql.listener.UpdateSpecificationSqlListener;
import io.seata.sqlparser.antlr.mysql.parser.MySqlLexer;
import io.seata.sqlparser.antlr.mysql.parser.MySqlParser;
import io.seata.sqlparser.antlr.mysql.stream.ANTLRNoCaseStringStream;
import io.seata.sqlparser.util.JdbcConstants;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;

Expand Down Expand Up @@ -72,6 +74,12 @@ public List<Object> getUpdateValues() {
return updateForValues.stream().map(updateValues -> updateValues.getUpdateValue()).collect(Collectors.toList());
}

@Override
public List<String> getUpdateColumnsIsSimplified() {
List<String> updateColumns = getUpdateColumns();
return ColumnUtils.delEscape(updateColumns, JdbcConstants.MYSQL);
}

@Override
public String getWhereCondition(ParametersHolder parametersHolder, ArrayList<List<Object>> paramAppenderList) {
return sqlContext.getWhereCondition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@ public interface SQLInsertRecognizer extends SQLRecognizer {
* @return the duplicateKey columns
*/
List<String> getDuplicateKeyUpdate();

/**
* Gets insert columns is Simplified.
*
* @return (`a`, `b`, `c`) -> (a, b, c)
*/
List<String> getInsertColumnsIsSimplified();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@ public interface SQLUpdateRecognizer extends WhereRecognizer {
* @return the update values
*/
List<Object> getUpdateValues();

/**
* Gets update columns is Simplified.
*
* @return (`a`, `b`, `c`) -> (a, b, c)
*/
List<String> getUpdateColumnsIsSimplified();
}
5 changes: 5 additions & 0 deletions sqlparser/seata-sqlparser-druid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<artifactId>druid</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-rm-datasource</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.druid.BaseRecognizer;
import io.seata.sqlparser.struct.Null;
import io.seata.sqlparser.util.JdbcConstants;

/**
* @author will
Expand Down Expand Up @@ -132,4 +133,7 @@ protected String getOrderByCondition(SQLOrderBy sqlOrderBy, final ParametersHold
return sb.toString();
}

public String getDbType() {
return JdbcConstants.MYSQL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor;
import io.seata.common.util.CollectionUtils;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.SQLInsertRecognizer;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.struct.NotPlaceholderExpr;
Expand Down Expand Up @@ -167,6 +168,12 @@ public List<String> getDuplicateKeyUpdate() {
return list;
}

@Override
public List<String> getInsertColumnsIsSimplified() {
List<String> insertColumns = getInsertColumns();
return ColumnUtils.delEscape(insertColumns, getDbType());
}

@Override
protected SQLStatement getAst() {
return ast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor;
import io.seata.common.exception.NotSupportYetException;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.SQLUpdateRecognizer;
Expand Down Expand Up @@ -102,6 +103,12 @@ public List<Object> getUpdateValues() {
return list;
}

@Override
public List<String> getUpdateColumnsIsSimplified() {
List<String> updateColumns = getUpdateColumns();
return ColumnUtils.delEscape(updateColumns, getDbType());
}

@Override
public String getWhereCondition(final ParametersHolder parametersHolder,
final ArrayList<List<Object>> paramAppenderList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.druid.BaseRecognizer;
import io.seata.sqlparser.struct.Null;
import io.seata.sqlparser.util.JdbcConstants;

/**
* @author will
Expand Down Expand Up @@ -166,4 +167,8 @@ public boolean visit(SQLInsertStatement x) {
getAst().accept(visitor);
return true;
}

public String getDbType() {
return JdbcConstants.ORACLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleInsertStatement;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
import io.seata.common.util.CollectionUtils;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.SQLInsertRecognizer;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.struct.NotPlaceholderExpr;
Expand Down Expand Up @@ -150,6 +151,12 @@ public List<String> getDuplicateKeyUpdate() {
return null;
}

@Override
public List<String> getInsertColumnsIsSimplified() {
List<String> insertColumns = getInsertColumns();
return ColumnUtils.delEscape(insertColumns, getDbType());
}

@Override
protected SQLStatement getAst() {
return ast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleUpdateStatement;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
import io.seata.common.exception.NotSupportYetException;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.SQLUpdateRecognizer;
Expand Down Expand Up @@ -100,6 +101,12 @@ public List<Object> getUpdateValues() {
return list;
}

@Override
public List<String> getUpdateColumnsIsSimplified() {
List<String> updateColumns = getUpdateColumns();
return ColumnUtils.delEscape(updateColumns, getDbType());
}

@Override
public String getWhereCondition(final ParametersHolder parametersHolder,
final ArrayList<List<Object>> paramAppenderList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.druid.BaseRecognizer;
import io.seata.sqlparser.struct.Null;
import io.seata.sqlparser.util.JdbcConstants;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -129,4 +131,8 @@ protected String getOrderByCondition(SQLOrderBy sqlOrderBy, final ParametersHold
executeOrderBy(sqlOrderBy, createOutputVisitor(parametersHolder, paramAppenderList, sb));
return sb.toString();
}

public String getDbType() {
return JdbcConstants.POSTGRESQL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor;
import io.seata.common.util.CollectionUtils;
import io.seata.common.util.StringUtils;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.SQLInsertRecognizer;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.struct.NotPlaceholderExpr;
Expand Down Expand Up @@ -160,6 +161,12 @@ public List<String> getDuplicateKeyUpdate() {
return null;
}

@Override
public List<String> getInsertColumnsIsSimplified() {
List<String> insertColumns = getInsertColumns();
return ColumnUtils.delEscape(insertColumns, getDbType());
}

@Override
protected SQLStatement getAst() {
return ast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGUpdateStatement;
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor;
import io.seata.common.exception.NotSupportYetException;
import io.seata.rm.datasource.ColumnUtils;
import io.seata.sqlparser.ParametersHolder;
import io.seata.sqlparser.SQLType;
import io.seata.sqlparser.SQLUpdateRecognizer;
Expand Down Expand Up @@ -98,6 +99,12 @@ public List<Object> getUpdateValues() {
return list;
}

@Override
public List<String> getUpdateColumnsIsSimplified() {
List<String> updateColumns = getUpdateColumns();
return ColumnUtils.delEscape(updateColumns, getDbType());
}

@Override
public String getWhereCondition(final ParametersHolder parametersHolder,
final ArrayList<List<Object>> paramAppenderList) {
Expand Down