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

optimize: When the number of primary keys exceeds 1000, use union to concatenate the SQL #6957 #7011

Closed
wants to merge 2 commits into from

Conversation

remind
Copy link
Contributor

@remind remind commented Nov 18, 2024

…oncatenate the SQL (#6957)

  • I have registered the PR changes.

Ⅰ. 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,修改了获取方式,是否有可能造成影响。

@funky-eyes funky-eyes added first-time contributor first-time contributor mode: AT AT transaction mode module/rm-datasource rm-datasource module labels Nov 18, 2024
@funky-eyes funky-eyes modified the milestone: 2.3.0 Nov 18, 2024
@remind remind closed this Nov 18, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

分支注册,主键超过1000的时候会转为or,但是使用or在mysql索引会失效
2 participants