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

Duplicate entry in global unique index report key 'UNKNOWN' #20949

Closed
pepezzzz opened this issue Nov 10, 2020 · 4 comments
Closed

Duplicate entry in global unique index report key 'UNKNOWN' #20949

pepezzzz opened this issue Nov 10, 2020 · 4 comments
Assignees
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.

Comments

@pepezzzz
Copy link

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 |

@pepezzzz pepezzzz added the type/bug The issue is confirmed as a bug. label Nov 10, 2020
@crazycs520
Copy link
Contributor

@tiancaiamao PTAL

@mjonss
Copy link
Contributor

mjonss commented Feb 14, 2022

Global index is not yet supported, and needs to be enabled in the config file by enable-global-index = true.

@mjonss
Copy link
Contributor

mjonss commented Feb 14, 2022

/component tablepartition

@ti-chi-bot ti-chi-bot added the component/tablepartition This issue is related to Table Partition of TiDB. label Feb 14, 2022
@bb7133
Copy link
Member

bb7133 commented Apr 25, 2022

Global partition is far from ready. I will mark it as 'won't fix' for now.

@bb7133 bb7133 added the wontfix This issue will not be fixed. label Apr 25, 2022
@bb7133 bb7133 closed this as completed Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

9 participants