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

rebase auto_increment in multi object ALTER TABLE does not update the same TiDB node's cached auto id. #47899

Closed
mjonss opened this issue Oct 21, 2023 · 1 comment · Fixed by #52967
Assignees
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Oct 21, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (a int not null auto_increment primary key, b int) auto_id_cache 100;
insert into t (b) values (1);
alter table t add column c int, auto_increment 200;
insert into t (b) values (2); -- I would expect this to generate at least a = 200!
select * from t;
show create table t\G

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

That the insert after the AUTO_INCREMENT was altered to 200 to be at least 200, not continue as nothing happened!

3. What did you see instead (Required)

tidb> create table t (a int not null auto_increment primary key, b int) auto_id_cache 100;
Query OK, 0 rows affected (0.09 sec)

tidb> insert into t (b) values (1);
Query OK, 1 row affected (0.01 sec)

tidb> alter table t add column c int, auto_increment 200;
Query OK, 0 rows affected (0.34 sec)

tidb> insert into t (b) values (2);
Query OK, 1 row affected (0.00 sec)

tidb> select * from t;
+---+------+------+
| a | b    | c    |
+---+------+------+
| 1 |    1 | NULL |
| 2 |    2 | NULL |
+---+------+------+
2 rows in set (0.01 sec)

tidb> show create table t\G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) DEFAULT NULL,
  `c` int(11) DEFAULT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=200 /*T![auto_id_cache] AUTO_ID_CACHE=100 */
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v7.5.0-alpha
Edition: Community
Git Commit Hash: 012869faded0a84e031b018e5a03c0f7d1ff021b
Git Branch: heads/refs/tags/v7.5.0-alpha
UTC Build Time: 2023-10-20 14:46:30
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Oct 21, 2023
@mjonss
Copy link
Contributor Author

mjonss commented Oct 22, 2023

Looks like only the first sub job will create a new schema diff. The following ones will skip it due to proxyJob.MultiSchemaInfo.SkipVersion = true here. @tangenta do you have any idea how to fix it?

@seiya-annie seiya-annie added severity/major component/ddl This issue is related to DDL of TiDB. labels Oct 23, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels Oct 23, 2023
@ti-chi-bot ti-chi-bot added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label Oct 23, 2023
@ti-chi-bot ti-chi-bot added the affects-8.1 This bug affects the 8.1.x(LTS) versions. label Apr 9, 2024
@D3Hunter D3Hunter self-assigned this Apr 28, 2024
@D3Hunter D3Hunter added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. and removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Apr 29, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
4 participants