1792
MariaDBERRORNotableData IntegrityHIGH confidence

Duplicate entry found in index — value unknown

Production Risk

Medium — DDL aborted; data has duplicates.

What this means

A unique constraint violation was detected during an operation but the exact duplicate value could not be determined (e.g., during InnoDB online DDL).

Why it happens
  1. 1A duplicate key was inserted into a unique index while an online ALTER TABLE was adding or rebuilding the index.
  2. 2Concurrent inserts during online DDL creating a duplicate that was not visible to the DDL thread.
How to reproduce
trigger — this will error
trigger — this will error
-- Occurs during concurrent inserts while ALTER TABLE ... ADD UNIQUE INDEX is running online

expected output

ERROR 1792 (23000): Duplicate entry '<unknown>' for key 'idx_unique'.

Fix

Find and resolve the duplicates, then re-run the ALTER

Find and resolve the duplicates, then re-run the ALTER
SELECT col, COUNT(*) FROM tbl GROUP BY col HAVING COUNT(*) > 1;
-- Deduplicate, then:
ALTER TABLE tbl ADD UNIQUE INDEX idx_unique (col);

Why this works

Removes all duplicate values before adding the unique constraint.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1792 ER_DUP_UNKNOWN_IN_INDEX

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors