1571
MariaDBWARNINGNotableData IntegrityHIGH confidence
Duplicate entry for auto-increment column
Production Risk
Medium — duplicate key warnings may surface as errors on strict replication targets.
What this means
A duplicate entry was generated for an auto-increment column when restoring from binary log in certain replication scenarios.
Why it happens
- 1Row-based replication replay generates an auto-increment value that already exists in the target table.
- 2Manual insertion of explicit auto-increment values followed by auto-generated values colliding.
How to reproduce
trigger — this will error
trigger — this will error
INSERT INTO t (id, val) VALUES (5, 'a');
-- then auto-increment catches up to 5
INSERT INTO t (val) VALUES ('b'); -- may generate id=5 againexpected output
Warning 1571: Auto-increment value collided during replication
Fix
Reset auto-increment value
Reset auto-increment value
ALTER TABLE t AUTO_INCREMENT = <max_id + 1>;
Why this works
After manually inserting explicit IDs, reset the auto-increment counter to avoid future collisions.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1571 ER_DUP_ENTRY_AUTOINCREMENT_CASE
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev