Tagged articles
replace_into
11 articles · Page 1 of 1
The article examines the drawbacks of using Snowflake for generating short numeric user IDs, details a MySQL auto‑increment based approach, reveals deadlock problems with REPLACE INTO, evaluates alternative schemes, and presents a final sharding‑friendly short‑ID design that meets performance and usability requirements.
MySQLShardingSnowflake
0 likes · 14 min read

This article explains how the REPLACE INTO statement can cause mismatched AUTO_INCREMENT values between MySQL master and replica after a failover, leading to primary‑key conflicts, and provides reproduction steps, underlying mechanics, and practical mitigation strategies.
Master‑SlaveMySQLReplication
0 likes · 9 min read

In MySQL 5.7, using REPLACE INTO on a table that has an auto‑increment primary key and an extra unique index can cause the master and slave AUTO_INCREMENT counters to diverge, leading to duplicate‑key errors after failover, a bug mitigated by upgrading to MySQL 8.0, manual counter fixes, or avoiding REPLACE INTO.
Binary LogMySQLauto-increment
0 likes · 18 min read

The article demonstrates via example how REPLACE INTO can cause data inconsistency and auto‑increment anomalies in master‑slave MySQL setups, explains the underlying binlog behavior, highlights risk points, and advises against using REPLACE when business logic depends on auto‑increment IDs.
Data ConsistencyMaster‑SlaveMySQL
0 likes · 7 min read

This article explains several MySQL techniques—INSERT IGNORE, ON DUPLICATE KEY UPDATE, and REPLACE INTO—to efficiently insert large volumes of data while preventing duplicate primary‑key or unique‑key rows, and provides practical code examples for single and batch operations.
INSERT IGNOREMySQLON DUPLICATE KEY UPDATE
0 likes · 6 min read

This article explains how MySQL unique indexes influence auto‑increment behavior, compares unique constraints with primary keys, and demonstrates three techniques—INSERT IGNORE, REPLACE INTO, and INSERT … ON DUPLICATE KEY UPDATE—to avoid duplicate‑key errors, including their effects on auto‑increment values and potential deadlocks.
Duplicate KeyINSERT IGNOREMySQL
0 likes · 10 min read

This article explains how MySQL UNIQUE indexes affect data insertion and auto‑increment behavior, compares them with primary keys, and presents three techniques—INSERT IGNORE, REPLACE INTO, and INSERT … ON DUPLICATE KEY UPDATE—to prevent duplicate‑key failures, including deadlock considerations.
Duplicate KeyINSERT IGNOREMySQL
0 likes · 8 min read


ITPUBNov 5, 2020 · Databases
After upgrading a critical MySQL 5.6 table to 5.7, the system began reporting duplicate‑key errors on master, replica and read‑only instances due to unexpected changes in the AUTO_INCREMENT value, prompting a deep kernel investigation, bug analysis, on‑site reproduction, and practical mitigation steps.
Duplicate KeyInnoDBMySQL
0 likes · 12 min read


ITPUBJul 18, 2020 · Databases
After upgrading a MySQL 5.6 master to 5.7, inserts on several InnoDB tables began failing with duplicate‑key errors because the auto_increment value became inconsistent, and the article walks through kernel‑level investigation, reproduction steps, bug analysis, and practical fixes.
Duplicate KeyInnoDBMySQL
0 likes · 11 min read

This article examines why MySQL auto‑increment primary keys can jump unexpectedly when using REPLACE INTO or INSERT … ON DUPLICATE KEY UPDATE, explains the role of innodb_autoinc_lock_mode, demonstrates examples, and offers practical solutions to prevent uncontrolled ID growth.
INSERT ON DUPLICATE KEY UPDATEMySQLauto-increment
0 likes · 11 min read

The article analyzes how MySQL’s REPLACE INTO statement can cause deadlocks by acquiring exclusive GAP locks during duplicate‑key handling, illustrates the issue with a step‑by‑step case study of three concurrent transactions, and recommends using pre‑check SELECT‑INSERT or serializing the statements to avoid the problem.
InnoDBLockMySQL
0 likes · 11 min read
