Skip to content

Using set as primary key results in inconsistent index #32302

Description

@ekexium

Bug Report

The case breaks the br integration test.

1. Minimal reproduce step (Required)

First turn off the mutation checker because it will find the inconsistency and abort the statement.

MySQL root@127.0.0.1:test> set @@tidb_enable_mutation_checker = 0;
Query OK, 0 rows affected
Time: 0.000s

MySQL root@127.0.0.1:test> CREATE TABLE `enum-set` (`set` SET(
                        -> 'x00','x01','x02','x03','x04','x05','x06','x07','x08','x09','x10','x11','x12','x13','x14','x15',
                        -> 'x16','x17','x18','x19','x20','x21','x22','x23','x24','x25','x26','x27','x28','x29','x30','x31',
                        -> 'x32','x33','x34','x35','x36','x37','x38','x39','x40','x41','x42','x43','x44','x45','x46','x47',
                        -> 'x48','x49','x50','x51','x52','x53','x54','x55','x56','x57','x58','x59','x60','x61','x62','x63'
                        -> ) NOT NULL PRIMARY KEY);
Query OK, 0 rows affected
Time: 0.110s

MySQL root@127.0.0.1:test> INSERT INTO `enum-set` VALUES("x00,x59");
Query OK, 1 row affected
Time: 0.007s

MySQL root@127.0.0.1:test> select `set` from `enum-set` where `set` like '%x00';
+-----+
| set |
+-----+
+-----+
0 rows in set
Time: 0.008s

MySQL root@127.0.0.1:test> select `set` from `enum-set` use index(PRIMARY);
+-----+
| set |
+-----+
| x59 |
+-----+
1 row in set
Time: 0.005s

MySQL root@127.0.0.1:test> select `set` from `enum-set` use index();
+---------+
| set     |
+---------+
| x00,x59 |
+---------+
1 row in set
Time: 0.008s

MySQL root@127.0.0.1:test> admin check table `enum-set`;
(8134, 'data inconsistency in table: enum-set, index: PRIMARY, col: set, handle: "1", index-values:"KindMysqlSet x59" != record-values:"KindMysqlSet x00,x59", compare err:<nil>')

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

Consistent results.

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

master.

tidb_version() | Release Version: v5.5.0-alpha-238-gf949e01e0b-dirty
Edition: Community
Git Commit Hash: f949e01e0b20cd74842558b42fa0bfa255146c0b
Git Branch: master
UTC Build Time: 2022-02-14 03:18:12
GoVersion: go1.17.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

Metadata

Metadata

Assignees

Labels

affects-4.0This bug affects 4.0.x versions.affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.severity/criticaltype/bugThe issue is confirmed as a bug.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions