MySQL 在执行 Online DDL 重建表的时候,可能会碰到 Duplicate
Entry 错误,从而导致 DDL 中途失败。失败信息如下所示:
1
2
mysql> alter table tt add c3 int, algorithm=inplace;
ERROR 1062 (23000): Duplicate entry '1' for key 'tt.uk_c2'
这是一个非常知名的问题,自从 MySQL-5.6 引入了 Online DDL 之后就一直存在。相关的Bug包括:
- BUG#76895[1] Adding new column OR Drop column causes duplicate PK error
- BUG#77572[2] The bogus duplicate key error in online ddl with incorrect key name
- BUG#98600[3] Optimize table fails with duplicate entry on UNIQUE KEY
- BUG#104626[4] Remove failure of Online ALTER because concurrent Duplicate entry.
BUG#76895[5]最早报告了这个问题。BUG#76895 上提到的是 Duplicate
PRIMARY …