Skip to content

AUTOINC NOT UPDATED PROPERLY DURING INSTANT ALTER TABLE LEADS TO DUPLICATE KEY #10

@xingyingone

Description

@xingyingone

description

To alter table instantly, InnoDB
forgot to remember the latest AUTOINC counter in dd::Table, thus after
reopening the table, it picked a stale AUTOINC value which was already
used.

how to fix

percona/percona-server@217c404#diff-908f0a52dfd64b4b26b052a5260840db33e12fcc322904fcb68ca9a6e8204d06

how to reproduce

use test;
drop table if exists t_in_def;
CREATE TABLE t_in_def (a serial key, b text) ;
INSERT INTO t_in_def(b) VALUES(repeat("a short string - ",5));
INSERT INTO t_in_def(b) VALUES(repeat("a long string - ",50));
INSERT INTO t_in_def(b) SELECT b FROM t_in_def;
SELECT a, left(b,50) FROM t_in_def;
SHOW CREATE TABLE t_in_def;

ALTER TABLE t_in_def ADD COLUMN (c int);
SHOW CREATE TABLE t_in_def;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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