Tagged articles
10 articles
Page 1 of 1
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.

REPLACE INTOauto_incrementbinary log
0 likes · 18 min read
Inconsistent AUTO_INCREMENT in MySQL 5.7 Replication Caused by REPLACE INTO
Java Architect Essentials
Java Architect Essentials
Jul 30, 2021 · Databases

How to Insert Non‑Duplicate Data in MySQL Using INSERT IGNORE, ON DUPLICATE KEY UPDATE, and REPLACE INTO

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 IGNOREON DUPLICATE KEY UPDATEREPLACE INTO
0 likes · 6 min read
How to Insert Non‑Duplicate Data in MySQL Using INSERT IGNORE, ON DUPLICATE KEY UPDATE, and REPLACE INTO
Code Ape Tech Column
Code Ape Tech Column
Mar 16, 2021 · Databases

How Unique Indexes Affect Auto-Increment and How to Handle Duplicate Keys in MySQL

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 IGNOREREPLACE INTO
0 likes · 10 min read
How Unique Indexes Affect Auto-Increment and How to Handle Duplicate 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.

Duplicate KeyINSERT IGNOREREPLACE INTO
0 likes · 8 min read
Impact of UNIQUE Indexes in MySQL and Strategies to Avoid Duplicate Key Errors
ITPUB
ITPUB
Nov 5, 2020 · Databases

Why Does MySQL 5.7 Throw Duplicate‑Key Errors After an Auto‑Increment Upgrade?

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.

BinlogDuplicate KeyInnoDB
0 likes · 12 min read
Why Does MySQL 5.7 Throw Duplicate‑Key Errors After an Auto‑Increment Upgrade?
ITPUB
ITPUB
Jul 18, 2020 · Databases

Why MySQL 5.7 Auto‑Increment Duplicates After Upgrade and How to Diagnose It

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.

BinlogBug AnalysisDuplicate Key
0 likes · 11 min read
Why MySQL 5.7 Auto‑Increment Duplicates After Upgrade and How to Diagnose It
Laravel Tech Community
Laravel Tech Community
Jul 5, 2020 · Databases

Understanding Auto‑Increment Gaps with REPLACE INTO and INSERT … ON DUPLICATE KEY UPDATE in MySQL

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 UPDATEREPLACE INTOauto_increment
0 likes · 11 min read
Understanding Auto‑Increment Gaps with REPLACE INTO and INSERT … ON DUPLICATE KEY UPDATE in MySQL
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