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

br doesn't rebase auto random if table's PKIsHandle is false #52255

Closed
Leavrth opened this issue Mar 30, 2024 · 2 comments · Fixed by #52256
Closed

br doesn't rebase auto random if table's PKIsHandle is false #52255

Leavrth opened this issue Mar 30, 2024 · 2 comments · Fixed by #52256
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. 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. component/br This issue is related to BR of TiDB. report/customer Customers have encountered this bug. severity/critical type/bug The issue is confirmed as a bug.

Comments

@Leavrth
Copy link
Contributor

Leavrth commented Mar 30, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

upstream:

CREATE TABLE test.t1 (a BIGINT PRIMARY KEY AUTO_RANDOM, b VARCHAR(255));
CREATE TABLE test.t2 (a BIGINT AUTO_RANDOM, b VARCHAR(255), PRIMARY KEY (`a`, `b`));

> SHOW CREATE TABLE test.t1;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                       |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
  `b` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=30001 */ |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

> SHOW CREATE TABLE test.t2;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                        |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
  `b` varchar(255) NOT NULL,
  PRIMARY KEY (`a`,`b`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=30001 */ |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

backup and restore

downstream:

> SHOW CREATE TABLE test.t1;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                       |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
  `b` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=30001 */ |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

> SHOW CREATE TABLE test.t2;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                         |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
  `b` varchar(255) NOT NULL,
  PRIMARY KEY (`a`,`b`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

duplicate key

upstream

CREATE TABLE test3.t (a BIGINT UNSIGNED AUTO_RANDOM(1), b VARCHAR(255), uid INT, c VARCHAR(255) DEFAULT 'c', PRIMARY KEY (`a`, `b`), UNIQUE INDEX (`uid`));

INSERT INTO test3.t (b, uid, c) values ('a', 1, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 2, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 3, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 4, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 5, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 6, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 7, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 8, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 9, 'a');
INSERT INTO test3.t (b, uid, c) values ('a', 10, 'a');

> table t;
+---------------------+---+------+------+
| a                   | b | uid  | c    |
+---------------------+---+------+------+
|                   1 | a |    1 | a    |
|                   3 | a |    3 | a    |
|                   4 | a |    4 | a    |
|                   5 | a |    5 | a    |
|                   7 | a |    7 | a    |
|                   9 | a |    9 | a    |
| 9223372036854775810 | a |    2 | a    |
| 9223372036854775814 | a |    6 | a    |
| 9223372036854775816 | a |    8 | a    |
| 9223372036854775818 | a |   10 | a    |
+---------------------+---+------+------+
10 rows in set (0.00 sec)

backup & restore

downstream

INSERT INTO test3.t (b, uid) values ('a', 10) on duplicate key update c = 'b';

> table t;
+---------------------+---+------+------+
| a                   | b | uid  | c    |
+---------------------+---+------+------+
|                   1 | a |    1 | b    |
|                   3 | a |    3 | a    |
|                   4 | a |    4 | a    |
|                   5 | a |    5 | a    |
|                   7 | a |    7 | a    |
|                   9 | a |    9 | a    |
| 9223372036854775810 | a |    2 | a    |
| 9223372036854775814 | a |    6 | a    |
| 9223372036854775816 | a |    8 | a    |
| 9223372036854775818 | a |   10 | a    |
+---------------------+---+------+------+
10 rows in set (0.00 sec)

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

the auto_rand_base of test.t2 need to be rebased by BR.

3. What did you see instead (Required)

the auto_rand_base of test.t2 isn't rebased by BR.

4. What is your TiDB version? (Required)

v6.5, v7.1, v7.5, master

@Leavrth Leavrth added type/bug The issue is confirmed as a bug. severity/critical component/br This issue is related to BR of TiDB. 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. labels Mar 30, 2024
@ti-chi-bot ti-chi-bot bot added may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Mar 30, 2024
@Leavrth Leavrth removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Mar 30, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 2, 2024
@BornChanger
Copy link
Contributor

/label affects-6.1

@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. 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. component/br This issue is related to BR of TiDB. report/customer Customers have encountered this bug. severity/critical type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants