Tag

Gap Lock

0 views collected around this technical thread.

Zhuanzhuan Tech
Zhuanzhuan Tech
Dec 26, 2024 · Backend Development

Analyzing MySQL 8.0 INSERT … ON DUPLICATE KEY UPDATE Deadlock and Source‑Code Investigation

This article investigates a deadlock that occurs when using INSERT … ON DUPLICATE KEY UPDATE in a multi‑threaded MySQL 8.0 environment, reproduces the issue, examines InnoDB lock logs, walks through the relevant source‑code call chain, and demonstrates how gap locks cause the deadlock.

Gap LockINSERTInnoDB
0 likes · 22 min read
Analyzing MySQL 8.0 INSERT … ON DUPLICATE KEY UPDATE Deadlock and Source‑Code Investigation
New Oriental Technology
New Oriental Technology
Jun 13, 2024 · Databases

Understanding InnoDB Row-Level Locks and Locking Rules in MySQL

This article explains the types of InnoDB row‑level locks—record lock, gap lock, and next‑key lock—describes how MySQL determines lock ranges based on indexing, outlines the two fundamental locking principles with associated optimizations, and provides concrete examples for primary‑key and ordinary indexes.

Gap LockInnoDBMySQL
0 likes · 11 min read
Understanding InnoDB Row-Level Locks and Locking Rules in MySQL
Zhuanzhuan Tech
Zhuanzhuan Tech
Jun 14, 2023 · Databases

Analyzing Gap‑Lock Deadlocks in MySQL When Using MyBatis‑Plus saveOrUpdate

This article investigates how the MyBatis‑Plus saveOrUpdate method can trigger gap‑lock deadlocks in MySQL, explains the underlying concepts of deadlocks and gap locks, reproduces the issue with concrete SQL scripts, and proposes both risky and recommended mitigation strategies.

DatabaseGap LockMyBatis-Plus
0 likes · 13 min read
Analyzing Gap‑Lock Deadlocks in MySQL When Using MyBatis‑Plus saveOrUpdate
IT Services Circle
IT Services Circle
Feb 8, 2023 · Databases

Understanding MySQL UPDATE Locking: Why Some Updates Block and Others Do Not

This article explains MySQL row‑level locking by analyzing three transactions—A, B, and C—to show why an UPDATE on a primary‑key column can block while an UPDATE on a non‑indexed column proceeds without waiting.

B+ TreeGap LockMySQL
0 likes · 7 min read
Understanding MySQL UPDATE Locking: Why Some Updates Block and Others Do Not
Tencent Database Technology
Tencent Database Technology
Jun 7, 2022 · Databases

Analysis of S‑Gap Lock Deadlocks under READ COMMITTED Isolation in InnoDB

This article investigates why S‑type GAP locks appear in deadlocks under the READ COMMITTED isolation level in MySQL InnoDB, detailing the transaction workflow, lock acquisition during INSERT operations, lock inheritance after rollbacks, and reproducing the deadlock scenario with code examples and diagrams.

DatabaseGap LockInnoDB
0 likes · 11 min read
Analysis of S‑Gap Lock Deadlocks under READ COMMITTED Isolation in InnoDB
政采云技术
政采云技术
Apr 26, 2022 · Databases

Analysis of Lock Wait Timeout and Gap Locks in InnoDB

This article analyzes a MySQL InnoDB lock wait timeout error, explains how gap locks cause blocked inserts and phantom reads under repeatable‑read isolation, and offers optimization strategies such as primary‑key deletions, while concluding with a recruitment invitation for the Zero technology team.

DatabaseGap LockInnoDB
0 likes · 7 min read
Analysis of Lock Wait Timeout and Gap Locks in InnoDB
Top Architect
Top Architect
Oct 3, 2021 · Databases

Understanding the INSERT Locking Process in MySQL by Analyzing the Source Code

This article examines MySQL's INSERT locking behavior, explains why phantom reads do not occur under REPEATABLE READ isolation, and walks through compiling the MySQL source, debugging lock acquisition, and the role of insert‑intention and gap locks using detailed code examples and execution traces.

Gap LockINSERTInnoDB
0 likes · 18 min read
Understanding the INSERT Locking Process in MySQL by Analyzing the Source Code
Beike Product & Technology
Beike Product & Technology
Jan 6, 2021 · Databases

Analyzing MySQL Deadlock Cases and Prevention Strategies

This article investigates a MySQL InnoDB deadlock observed during a holiday period, explains how gap locks and next‑key locks on a composite index cause mutual waiting, reproduces the issue with large test data, and offers practical guidelines to avoid similar deadlocks in production environments.

Gap LockInnoDBMySQL
0 likes · 12 min read
Analyzing MySQL Deadlock Cases and Prevention Strategies
Selected Java Interview Questions
Selected Java Interview Questions
Sep 17, 2020 · Databases

Understanding MySQL Gap Locks and Next‑Key Locks with Practical Examples

This article explains how InnoDB implements row locks, gap locks, and next‑key locks to prevent phantom reads, describes how the lock ranges are determined, and demonstrates their effects through multiple transaction scenarios with detailed SQL code examples.

Gap LockInnoDBMySQL
0 likes · 11 min read
Understanding MySQL Gap Locks and Next‑Key Locks with Practical Examples
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jun 24, 2020 · Databases

Comprehensive Guide to MySQL Lock Mechanisms: Table, Row, Gap Locks and Deadlock Handling

This article provides a detailed overview of MySQL's locking mechanisms—including table, row, gap, and deadlock handling—across MyISAM and InnoDB storage engines, with practical code examples, performance considerations, and solutions for high‑concurrency scenarios.

Gap LockInnoDBLock Mechanism
0 likes · 19 min read
Comprehensive Guide to MySQL Lock Mechanisms: Table, Row, Gap Locks and Deadlock Handling
Selected Java Interview Questions
Selected Java Interview Questions
Mar 16, 2020 · Databases

Understanding MySQL Table Locks, Row Locks, and Gap Locks

This article explains the differences between MySQL table locks and row locks, describes how MyISAM and InnoDB handle locking, provides explicit lock syntax with examples, discusses gap locks, and offers practical recommendations for avoiding lock contention in concurrent applications.

Gap LockInnoDBLocks
0 likes · 7 min read
Understanding MySQL Table Locks, Row Locks, and Gap Locks
Aikesheng Open Source Community
Aikesheng Open Source Community
Apr 1, 2019 · Databases

MySQL Insert Locking, Insert‑Intention Locks, Gap Locks, and Deadlock Analysis

This article examines MySQL's insert locking behavior, including unique‑key checks, S Next‑Key locks, insert‑intention locks, gap locks, and the resulting deadlock scenarios, and provides practical recommendations for avoiding such lock conflicts in production environments.

DatabaseGap LockINSERT
0 likes · 10 min read
MySQL Insert Locking, Insert‑Intention Locks, Gap Locks, and Deadlock Analysis
Manbang Technology Team
Manbang Technology Team
Sep 21, 2018 · Databases

MySQL Deadlock Analysis: GAP Locks, Phantom Reads, and How to Resolve Them

This article examines why concurrent upsert operations in a high‑throughput MySQL service can cause deadlocks due to GAP locks and phantom reads, explains the underlying InnoDB locking mechanisms, and offers practical solutions such as adjusting isolation levels or redesigning data sharding logic.

DatabaseGap LockMySQL
0 likes · 9 min read
MySQL Deadlock Analysis: GAP Locks, Phantom Reads, and How to Resolve Them