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

[fix] : avoid the case that increservice may fill duplicated number in multi-CN #19031

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jensenojs
Copy link
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #16493

What this PR does / why we need it:

  • 在 incr service 给自增列生成值之前, 用户可能已经手动地插入过incr service cache住的区间的值了
    • 如果不感知这个事情, 那incr service 会生成实际上是重复的数据.
  • 现在补充利用PrimaryKeysMayBeModified做检测, 在遇到这种情况会直接retry, 重新从incr service里面拿值.

@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Sep 26, 2024
@mergify mergify bot added the kind/bug Something isn't working label Sep 26, 2024
@jensenojs
Copy link
Contributor Author

jensenojs commented Sep 26, 2024

背景

这个bug fix的一个背景是想要重新争取优化掉对于下面的insert的主键去重的开销.

create table t(a int auto-increment primary key, b int);
insert into t(b) values (1); -- 其他的CN上可能手动地插入了这个CN的incrService cache住的自增区间的值. 

在主键去重开启的时候, 大不了insert into t(b) values (1);就报个用户不能理解的 Duplicate key的问题, 重试就可以了. 但在关闭去重检测之后这样做就会有正确性问题. 这个pr做的事情就是要确保 —— 不管后续优化到底是如何做, 都不会有正确性问题.

之前提过一次pr, 但被revert了, revert的原因是没有考虑到远端CN在执行的时候没有workspace的信息, 因此在Engine拿表和做检测的时候没有通过相关的防御性代码.

relative

相关tke的runner : https://github.com/matrixorigin/ci-test/actions/runs/11047965332

后续优化的选项控制的issue跟踪 : #15723

@jensenojs
Copy link
Contributor Author

jensenojs commented Sep 27, 2024

向旭哥请教了一下, 检测在preinsert算子内部做在一些场景下仍然会有问题. 要重新改一下, 后面会补充相关的集成测试. 这个pr暂时先不能合


update :

https://github.com/matrixorigin/ci-test/actions/runs/11100985195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants