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 · 1 comment · Fixed by #52256
Closed

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

Leavrth opened this issue Mar 30, 2024 · 1 comment · Fixed by #52256

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

@BornChanger
Copy link
Contributor

/label affects-6.1

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

Successfully merging a pull request may close this issue.

2 participants