Duplicate entry in global unique index report key 'UNKNOWN' #20949
Labels
component/tablepartition
This issue is related to Table Partition of TiDB.
severity/minor
sig/sql-infra
SIG: SQL Infra
type/bug
The issue is confirmed as a bug.
wontfix
This issue will not be fixed.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
MySQL [test1106]> create table t_part_pk_id2(id int primary key, studentid int(10)) partition by hash(id) partitions 2;
Query OK, 0 rows affected (0.08 sec)
MySQL [test1106]> alter table t_part_pk_id2 add unique index(studentid);
Query OK, 0 rows affected (2.78 sec)
MySQL [test1106]> show create table t_part_pk_id2;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t_part_pk_id2 | CREATE TABLE
t_part_pk_id2
(id
int(11) NOT NULL,studentid
int(10) DEFAULT NULL,PRIMARY KEY (
id
),UNIQUE KEY
studentid
(studentid
)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH(
id
)PARTITIONS 2 |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
MySQL [test1106]> alter table t_part_pk_id2 alter partition p0
-> alter placement policy constraints='["+host=host71"]' role=leader replicas=1,
-> alter placement policy constraints='["-host=host71"]' role=follower replicas=2;
Query OK, 0 rows affected (0.08 sec)
MySQL [test1106]> alter table t_part_pk_id2 alter partition p1
-> alter placement policy constraints='["+host=host30"]' role=leader replicas=1,
-> alter placement policy constraints='["-host=host30"]' role=follower replicas=2;
Query OK, 0 rows affected (0.08 sec)
MySQL [test1106]> insert into t_part_pk_id1 values(1,1),(2,2),(3,3),(4,4);
ERROR 1062 (23000): Duplicate entry '7480000000000001835f698000000000000001038000000000000001' for key 'UNKNOWN'
MySQL [test1106]> insert into t_part_pk_id2 values(1,1),(2,2),(3,3),(4,4);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
MySQL [test1106]> insert into t_part_pk_id2 values(1,5);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
MySQL [test1106]> insert into t_part_pk_id2 values(5,1);
ERROR 1062 (23000): Duplicate entry '74800000000000018a5f698000000000000001038000000000000001' for key 'UNKNOWN'
by contrast,normal unique index report the real name.
MySQL [test1106]> create table t_part_pk_id3(id int primary key, studentid int(10)) ;
Query OK, 0 rows affected (0.08 sec)
MySQL [test1106]> alter table t_part_pk_id3 add unique index(studentid);
Query OK, 0 rows affected (2.78 sec)
MySQL [test1106]> show create table t_part_pk_id3;
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t_part_pk_id3 | CREATE TABLE
t_part_pk_id3
(id
int(11) NOT NULL,studentid
int(10) DEFAULT NULL,PRIMARY KEY (
id
),UNIQUE KEY
studentid
(studentid
)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MySQL [test1106]> insert into t_part_pk_id3 values(1,1),(2,2),(3,3),(4,4);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
MySQL [test1106]> insert into t_part_pk_id3 values(1,5);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
MySQL [test1106]> insert into t_part_pk_id3 values(5,1);
ERROR 1062 (23000): Duplicate entry '1' for key 'studentid'
2. What did you expect to see? (Required)
the real global index name
3. What did you see instead (Required)
ERROR 1062 (23000): Duplicate entry '74800000000000018a5f698000000000000001038000000000000001' for key 'studentid'
4. What is your TiDB version? (Required)
| Release Version: v4.0.0-beta.2-1462-g280e8aa35-dirty
Edition: Community
Git Commit Hash: 280e8aa
Git Branch: master
UTC Build Time: 2020-10-31 13:35:02
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
The text was updated successfully, but these errors were encountered: