Tagged articles

Next-Key Lock

15 articles · Page 1 of 1
Wukong Talks Architecture
Wukong Talks Architecture
May 28, 2026 · Databases

Understanding MySQL InnoDB Locks: Types, Queries, and Common Pitfalls

This article explains InnoDB's lock mechanisms—including table, intention, row, GAP, next‑key, and auto‑increment locks—shows how to inspect them via performance_schema tables, demonstrates lock behavior under different isolation levels with concrete SQL examples, and clarifies lock compatibility rules.

GAP LockInnoDBIsolation Levels
0 likes · 20 min read
Understanding MySQL InnoDB Locks: Types, Queries, and Common Pitfalls
Sanyou's Java Diary
Sanyou's Java Diary
Aug 25, 2025 · Databases

Understanding MySQL Next-Key Locks: Preventing Phantom Reads and Deadlocks

This article explains MySQL InnoDB's Next-Key Lock mechanism, how it combines row and gap locks to prevent phantom reads under the REPEATABLE READ isolation level, illustrates lock ranges with examples, discusses when it degrades to row or gap locks, and highlights its advantages and potential deadlock risks.

DeadlockInnoDBMySQL
0 likes · 8 min read
Understanding MySQL Next-Key Locks: Preventing Phantom Reads and Deadlocks
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
ITPUB
ITPUB
Jul 28, 2023 · Databases

Master InnoDB Row Locking: Rules, Examples, and How Locks Are Applied

This article explains InnoDB's three row‑lock types, when MySQL statements acquire implicit or explicit locks, and walks through concrete examples for unique and non‑unique index queries, showing how Next‑key, Record and Gap locks are determined.

Database ConcurrencyInnoDBMySQL
0 likes · 10 min read
Master InnoDB Row Locking: Rules, Examples, and How Locks Are Applied
政采云技术
政采云技术
Feb 23, 2023 · Databases

Understanding Next-Key Lock Deadlocks in MySQL: Analysis and Solutions

This article examines how common business operations using SELECT ... FOR UPDATE and INSERT can cause MySQL Next‑Key lock deadlocks, explains the underlying gap‑lock and row‑lock mechanisms, demonstrates practical experiments, and proposes strategies such as postponing locks or using primary‑key updates to avoid such deadlocks.

DatabaseDeadlockLocking
0 likes · 14 min read
Understanding Next-Key Lock Deadlocks in MySQL: Analysis and Solutions
政采云技术
政采云技术
Feb 21, 2023 · Databases

Understanding Next-Key Lock Deadlocks in MySQL and How to Avoid Them

This article examines how common business operations using SELECT ... FOR UPDATE and INSERT can cause Next‑Key lock deadlocks in MySQL under repeatable‑read isolation, demonstrates the locking behavior with practical SQL examples, and proposes strategies such as post‑locking and primary‑key updates to prevent such deadlocks.

DatabaseDeadlockMySQL
0 likes · 14 min read
Understanding Next-Key Lock Deadlocks in MySQL and How to Avoid Them
ITPUB
ITPUB
Feb 8, 2023 · Databases

Why Does One MySQL UPDATE Block While Another Doesn’t? A Deep Dive into Row‑Level Locks

This article explains why an UPDATE on a MySQL row that changes a regular column proceeds without blocking, while an UPDATE that modifies the primary‑key value gets blocked, by analyzing the locks set by preceding transactions, the B+‑tree index structure, and the delete‑plus‑insert rewrite performed by InnoDB.

B+TreeGAP LockMySQL
0 likes · 9 min read
Why Does One MySQL UPDATE Block While Another Doesn’t? A Deep Dive into Row‑Level Locks
政采云技术
政采云技术
Jul 28, 2022 · Databases

Analyzing and Resolving MySQL Next‑Key Lock Deadlocks: A Practical Case Study

This article walks through a real MySQL deadlock scenario, explaining the four necessary deadlock conditions, illustrating how Next‑Key locks on non‑unique indexes cause gap locks, and presenting step‑by‑step analysis, experimental verification, and practical recommendations to avoid such deadlocks in production systems.

DatabaseDeadlockLocking
0 likes · 15 min read
Analyzing and Resolving MySQL Next‑Key Lock Deadlocks: A Practical Case Study
Selected Java Interview Questions
Selected Java Interview Questions
Sep 27, 2020 · Databases

Understanding How MySQL InnoDB Solves Phantom Reads

This article explains the four transaction isolation levels, defines phantom reads, and details how MySQL's InnoDB engine uses MVCC snapshot reads and next‑key locking (including the next‑key principle and lock composition) to prevent phantom reads under the REPEATABLE READ isolation level.

InnoDBMVCCMySQL
0 likes · 2 min read
Understanding How MySQL InnoDB Solves Phantom Reads
dbaplus Community
dbaplus Community
Mar 17, 2019 · Databases

Understanding InnoDB Locks: From Record Locks to Deadlocks

This article explains MySQL InnoDB’s transaction locking mechanisms—including shared, exclusive, intention, gap, and next‑key locks—covers lock compatibility, demonstrates lock behavior with practical examples, explores phantom reads, lost updates, optimistic vs. pessimistic locking, and analyzes common deadlock scenarios.

DeadlockGAP LockInnoDB
0 likes · 28 min read
Understanding InnoDB Locks: From Record Locks to Deadlocks
ITPUB
ITPUB
Oct 17, 2016 · Databases

Why Some MySQL Inserts Are Blocked: Decoding Next‑Key Lock Ranges

This article examines MySQL InnoDB's next‑key lock behavior by creating a test table, running concurrent transactions, and analyzing how the lock range is determined across primary and secondary index columns, revealing why certain insert statements are blocked while others succeed.

GAP LockInnoDBMySQL
0 likes · 9 min read
Why Some MySQL Inserts Are Blocked: Decoding Next‑Key Lock Ranges