Tag

Replace Into

0 views collected around this technical thread.

vivo Internet Technology
vivo Internet Technology
Apr 3, 2024 · Databases

Inconsistent AUTO_INCREMENT in MySQL 5.7 Replication Caused by REPLACE INTO

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.

DatabaseMySQLReplace Into
0 likes · 18 min read
Inconsistent AUTO_INCREMENT in MySQL 5.7 Replication Caused by REPLACE INTO
Aikesheng Open Source Community
Aikesheng Open Source Community
Dec 6, 2022 · Databases

Risks of Using REPLACE INTO with Auto-Increment Primary Keys in MySQL

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.

Master‑SlaveMySQLReplace Into
0 likes · 7 min read
Risks of Using REPLACE INTO with Auto-Increment Primary Keys in MySQL
Architecture Digest
Architecture Digest
Mar 15, 2021 · Databases

Impact of UNIQUE Indexes in MySQL and Strategies to Avoid Duplicate Key Errors

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.

DatabaseINSERT IGNOREMySQL
0 likes · 8 min read
Impact of UNIQUE Indexes in MySQL and Strategies to Avoid Duplicate Key Errors
Youzan Coder
Youzan Coder
Feb 20, 2019 · Databases

MySQL REPLACE INTO Deadlock: Case Study and Analysis

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.

Case StudyInnoDBLock
0 likes · 11 min read
MySQL REPLACE INTO Deadlock: Case Study and Analysis