optimize: When the number of primary keys exceeds 1000, use union to concatenate the SQL #6957 #7012
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…oncatenate the SQL (#6957)
Ⅰ. Describe what this PR did
When the number of primary keys exceeds 1000, use union to concatenate the SQL
Ⅱ. Does this pull request fix one issue?
fixes #6957
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
sql生成有测试用例:
io.seata.rm.datasource.SqlGenerateUtilsTest
此测试类之前已经存在,此次在此基础上进行了修改
其它受影响的地方依赖其它已有测试用例,由于该问题的触发场景比较极端,必须要超过1000个主键,并且该1000的配置是private的,有部分场景没看到之前有编写超过1000时的测试用例,本地通过修改配置值进行了单元测试,不确定集成测试是否有此场景的测试。
Ⅴ. Special notes for reviews
1、io.seata.rm.datasource.undo.AbstractUndoExecutor#queryCurrentRecords 该方法是使用了
For Update
,之前是一条sql一次性执行完,当主键数量超过1000时现在会拆分成多条sql循环执行,每条执行会有间隔,如果有同样的数据重复处理,并且是不同事务的,可能会导致死锁。2、由于sql采用了union拼接,影响到了
SQLSelectQueryBlock
的获取,因此在*SelectForUpdateRecognizer
此种类中,如io.seata.sqlparser.druid.mysql.MySQLSelectForUpdateRecognizer#getSelect
,修改了获取方式,是否有可能造成影响。