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

after importing NONCLUSTERED auto_increment and AUTO_ID_CACHE=1 table by lightning,insert report "duplicate entry" #46100

Closed
mayjiang0203 opened this issue Aug 15, 2023 · 4 comments · Fixed by #46171
Labels
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.3 component/lightning This issue is related to Lightning of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@mayjiang0203
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Following is schema that will import by lighting

cat smalldb.t1-schema.sql
CREATE TABLE `t1` (
    `cacheid` int(11) NOT NULL AUTO_INCREMENT,
    `rk` varchar(16) NOT NULL,
    `cfq` varchar(10) NOT NULL,
    `ts` bigint(20) NOT NULL,
    `value` varchar(2048) DEFAULT NULL,
    PRIMARY KEY(`cacheid`) NONCLUSTERED)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_ID_CACHE 1;

After import finished, hit following error when try to insert new rows.

mysql> show table t1 next_row_id;
+---------+------------+-------------+--------------------+----------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE        |
+---------+------------+-------------+--------------------+----------------+
| smalldb | t1         | _tidb_rowid |                  1 | _TIDB_ROWID    |
| smalldb | t1         | _tidb_rowid |          577898371 | AUTO_INCREMENT |
+---------+------------+-------------+--------------------+----------------+
2 rows in set (0.21 sec)

mysql> select count(*) from t1;
+----------+
| count(*) |
+----------+
|  3960000 |
+----------+
1 row in set (0.78 sec)

mysql> show create table t1;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                                                                              |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `cacheid` int(11) NOT NULL AUTO_INCREMENT,
  `rk` varchar(16) NOT NULL,
  `cfq` varchar(10) NOT NULL,
  `ts` bigint(20) NOT NULL,
  `value` varchar(2048) DEFAULT NULL,
  PRIMARY KEY (`cacheid`) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=577898371 /*T![auto_id_cache] AUTO_ID_CACHE=1 */ |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.20 sec)

mysql> select max(cacheid) from t1;
+--------------+
| max(cacheid) |
+--------------+
|      3960000 |
+--------------+
1 row in set (0.20 sec)

mysql> insert into t1(rk,cfq,ts) values('rk_txxxxxxxxx','cfg_xxxxx',7);
ERROR 1062 (23000): Duplicate entry '?' for key 't1.PRIMARY'

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

v7.3.0

@mayjiang0203 mayjiang0203 added the type/bug The issue is confirmed as a bug. label Aug 15, 2023
@mayjiang0203
Copy link
Author

same with #46093

@D3Hunter D3Hunter added the component/lightning This issue is related to Lightning of TiDB. label Aug 15, 2023
@D3Hunter
Copy link
Contributor

reopen it for lightning side

@D3Hunter D3Hunter reopened this Aug 15, 2023
@D3Hunter D3Hunter added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. labels Aug 15, 2023
@D3Hunter
Copy link
Contributor

D3Hunter commented Aug 15, 2023

this affects >=6.5 version, when enabling AUTO_ID_CACHE=1(auto_id and _tidb_rowid use different allocator), and table has implicit _tidb_rowid col

@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 17, 2023
@seiya-annie seiya-annie added severity/critical and removed may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 severity/major labels Aug 17, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 17, 2023
@seiya-annie
Copy link

seiya-annie commented Aug 17, 2023

need add a system test case for lightning by QA

@D3Hunter D3Hunter added severity/major and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 17, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 17, 2023
@D3Hunter D3Hunter removed may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 17, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 17, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 18, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 18, 2023
@D3Hunter D3Hunter changed the title AUTO_INCREMENT increase too large after importing NONCLUSTERED AUTO_ID_CACHE=1 table by lightning after importing NONCLUSTERED AUTO_ID_CACHE=1 table by lightning,insert report "duplicate entry" Aug 21, 2023
@D3Hunter D3Hunter changed the title after importing NONCLUSTERED AUTO_ID_CACHE=1 table by lightning,insert report "duplicate entry" after importing NONCLUSTERED auto_increment and AUTO_ID_CACHE=1 table by lightning,insert report "duplicate entry" Aug 21, 2023
ti-chi-bot bot pushed a commit that referenced this issue Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.3 component/lightning This issue is related to Lightning of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
4 participants