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

Got duplicate entry error for auto increment column #53016

Closed
guo-shaoge opened this issue May 1, 2024 · 2 comments
Closed

Got duplicate entry error for auto increment column #53016

guo-shaoge opened this issue May 1, 2024 · 2 comments

Comments

@guo-shaoge
Copy link
Collaborator

guo-shaoge commented May 1, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. apply tidb code, check detail code from when leader switch, autoid service does not reset the map #52600. So we can reassign auto_id service leader
  2. setup tidb cluster(2 tidb/1 tikv/1 pd)
  3. By running following command to make sure auto_id leader is in tidb-0(10080). (command result is 'not owner')
curl http://127.0.0.1:10081/autoid/leader/resign
result: not owner
  1. run the following sql to create table:
create table t (id int primary key auto_increment, k int) auto_id_cache = 1;
insert into t (k) values (1);
insert into t (k) values (2);
insert into t (k) values (3);
insert into t (k) values (5);
  1. reassign autoid leader to tidb-1(10081). (the result of the command should be success)
curl http://127.0.0.1:10080/autoid/leader/resign
  1. run the following sqls to insert again:
insert into t (k) values (6);
insert into t (k) values (7);
insert into t (k) values (8);
  1. tiup restart tidb-1(10081)
  2. tiup restart tidb-0(10080)
  3. run the following sqls to insert 4000 lines: t.txt
source /home/guojiangtao/work/tidb/t.txt;

2. What did you expect to see? (Required)

insert runs ok

3. What did you see instead (Required)

img_v3_02af_d95c0cd9-5ec4-418f-a411-b58310ecf73g

4. What is your TiDB version? (Required)

+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                           |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.1.0-alpha-1-g42f4a3133d
Edition: Community
Git Commit Hash: 42f4a3133d8cc5309a5fa4dd7c92a2a1cfa3cbca
Git Branch: debug_autoid
UTC Build Time: 2024-05-01 06:19:47
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.009 sec)
@tiancaiamao
Copy link
Contributor

Duplicated with #52600

Are you testing with 8.1? It has not merge the cherry-pick yet #53000
@guo-shaoge

@guo-shaoge
Copy link
Collaborator Author

Duplicated with #52600

Are you testing with 8.1? It has not merge the cherry-pick yet #53000 @guo-shaoge

No, I tested it with v7.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants