Bug #36988 | Documentation on Next-Key Locking is confusing and misleading | ||
---|---|---|---|
Submitted: | 26 May 2008 18:34 | Modified: | 1 Dec 2008 20:42 |
Reporter: | Gordon Shannon | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.1.24-rc-community-log | OS: | Any |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
Tags: | gap locking, next-key locks, phantom reads |
[26 May 2008 18:34]
Gordon Shannon
[26 May 2008 20:35]
Sveta Smirnova
Thank you for the report. I agree "gap" part is not clear from the manual. According to "select * from gs where id < 100 lock in share mode;" part, there is example in the manual which starts from "select * from gs where id < 100 lock in share mode;" So report is partially verified as documenatation bug.
[20 Jun 2008 18:32]
Paul DuBois
Your table definition does not include ENGINE = InnoDB, so there will certainly be no blocking if the table is creating using the default engine (MyISAM). Was your environment such that InnoDB was the default table type?
[20 Jun 2008 18:37]
Gordon Shannon
Innodb is our default engine type.
[21 Jun 2008 17:52]
Paul DuBois
Re: Issue #2: " -- Session B: set session tx_isolation='REPEATABLE-READ'; -- 3 is *not* immediately before 5, but this still blocks... insert into gs values (3,1500); " 3 as a value does not immediately precede the value 5, but it's in the gap that immediately precedes 5 (i.e., the gap from 2 through 4). You should find similar blocking where you to insert 2 or 4.
[1 Dec 2008 20:42]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products. Gap locks and next-key locks are not the same. A next-key lock is an index-record lock plus a gap lock before the index record. Please see: http://dev.mysql.com/doc/refman/5.0/en/innodb-record-level-locks.html (This is a new section that did not exist when you submitted this bug report.) Issue 1: The behavior you see occurs because gap locking is used for locking ranges, not unique records. Issue 2: re: "3 is *not* immediately before 5, but this still blocks": True, 3 is not immediately before 5, but the gap that includes 3 is. (The gap between 1 and 5 includes the values 2, 3, 4.) Issue 3: The section quoted does actually say that the gap following the last index record can be locked. It's just not in the part you quoted. However, I've revised the section to make this more obvious. (At least, I hope it's more obvious. Please take a look and see.)