Record, Gap & Next-Key Locks
Learn Record, Gap & Next-Key Locks (Locks & Concurrency, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Introduction Under REPEATABLE READ, InnoDB locks more than the rows it finds. A record lock locks one index record. A gap lock locks the open interval between two index records (stopping inserts there). A next-key lock is a record lock plus the gap before it, and is the default range lock.