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] : fix increservice fill duplicated number during in multi-CN #17381

Merged
merged 12 commits into from
Jul 16, 2024

Conversation

jensenojs
Copy link
Contributor

@jensenojs jensenojs commented Jul 8, 2024

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:

preInsert算子在给auto pk col生成值后, 会再加一个Relation.PrimaryKeysMayBeModified的检查, 检查columnCache更新的最后时间段(fromTS), 到此次sql期间(toTS), incrservice给出的值是否已经被Modified了, 如果是的话, 那直接retry这个sql.

这个场景会出现的原因是, 用户于其他的CNinsert auto pk col的时候手动指定了values的值, 并且这个值是在本CN的incrservice cache的区间中.

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jul 8, 2024
@jensenojs jensenojs marked this pull request as draft July 8, 2024 09:54
@jensenojs jensenojs marked this pull request as ready for review July 8, 2024 10:50
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Jul 9, 2024
@jensenojs jensenojs changed the title [enhancement] : Maintain the last modified TxnTs fields for each columnCache [fix] : fix increservice fill duplicated number during multi-CN Jul 9, 2024
@mergify mergify bot added the kind/bug Something isn't working label Jul 9, 2024
@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Jul 10, 2024
@jensenojs
Copy link
Contributor Author

jensenojs commented Jul 11, 2024

本地用launch-dynamic-with-proxy启动, 在main上的测试结果如下所示 : 其中左侧是CN0(-P16001), 右侧是CN1(-P16002)

--- 复现步骤

-- step1
-- mysql -h 127.0.0.1 -P16001 -uroot -p111 --local-infile
create database insert_auto_pk; use insert_auto_pk;
drop table if exists t0;
create table t0(a int auto_increment, b int, primary key(a));
insert into t0(b) values (1), (2);

-- step2
-- @session:id=1{
-- mysql -h 127.0.0.1 -P16002 -uroot -p111 --local-infile
use insert_auto_pk;
insert into t0(a) values (3);
-- @session}

-- step3
-- mysql -h 127.0.0.1 -P16001 -uroot -p111 --local-infile
insert into t0(b) values (1), (2);
image

在step3中会发现插入的时候报duplicate, 但此时用户并没有指定值.


image

在此pr中会retry这个sql

@jensenojs jensenojs changed the title [fix] : fix increservice fill duplicated number during multi-CN [fix] : fix increservice fill duplicated number during in multi-CN Jul 11, 2024
pkg/incrservice/allocator.go Outdated Show resolved Hide resolved
pkg/incrservice/allocator_test.go Outdated Show resolved Hide resolved
pkg/incrservice/column_cache.go Outdated Show resolved Hide resolved
pkg/incrservice/column_cache.go Show resolved Hide resolved
pkg/incrservice/column_cache.go Outdated Show resolved Hide resolved
pkg/incrservice/column_cache.go Show resolved Hide resolved
pkg/incrservice/column_cache.go Outdated Show resolved Hide resolved
@mergify mergify bot merged commit 07dd980 into matrixorigin:main Jul 16, 2024
17 of 18 checks passed
@jensenojs jensenojs deleted the fix-16493 branch July 17, 2024 02:07
jensenojs added a commit to jensenojs/matrixone that referenced this pull request Jul 17, 2024
jensenojs added a commit to jensenojs/matrixone that referenced this pull request Jul 26, 2024
…atrixorigin#17381)

`preInsert`算子在给`auto pk col`生成值后, 会再加一个`Relation.PrimaryKeysMayBeModified`的检查, 检查`columnCache`更新的最后时间段(`fromTS`), 到此次sql期间(`toTS`), `incrservice`给出的值是否已经被`Modified`了, 如果是的话, 那直接retry这个sql.

这个场景会出现的原因是, 用户于其他的`CN`在`insert auto pk col`的时候手动指定了`values`的值, 并且这个值是在本CN的`incrservice cache`的区间中.
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 kind/enhancement size/L Denotes a PR that changes [500,999] lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants