-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
optimize: When the number of primary keys exceeds 1000, use union to concatenate the SQL #6957 #7012
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…concatenate the SQL. (apache#6957)
funky-eyes
added
first-time contributor
first-time contributor
mode: AT
AT transaction mode
module/rm-datasource
rm-datasource module
type: optimize
labels
Nov 19, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7012 +/- ##
============================================
- Coverage 52.66% 52.65% -0.01%
- Complexity 6643 6663 +20
============================================
Files 1126 1129 +3
Lines 40142 40168 +26
Branches 4707 4708 +1
============================================
+ Hits 21139 21151 +12
- Misses 16990 17000 +10
- Partials 2013 2017 +4
|
…concatenate the SQL. (apache#6957)
…concatenate the SQL. (apache#6957)
…concatenate the SQL. (apache#6957)
funky-eyes
approved these changes
Dec 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
first-time contributor
first-time contributor
mode: AT
AT transaction mode
module/rm-datasource
rm-datasource module
type: optimize
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
,修改了获取方式,是否有可能造成影响。