When you rebuild a table with MySQL’s Online DDL, the operation
can fail partway through with a Duplicate Entry
error:
1
2
mysql> alter table tt add c3 int, algorithm=inplace;
ERROR 1062 (23000): Duplicate entry '1' for key 'tt.uk_c2'
This is a long-standing, well-known problem — it has existed ever since Online DDL was introduced in MySQL 5.6, and it appears across several bug reports:
- BUG#76895 — Adding new column OR Drop column causes duplicate PK error
- BUG#77572 — The bogus duplicate key error in online ddl with incorrect key name
- BUG#98600 — Optimize table fails with duplicate entry on UNIQUE …