Bug #63665 | X row locks do not prevent an IX table lock, contrary to documentation | ||
---|---|---|---|
Submitted: | 8 Dec 2011 11:12 | Modified: | 8 Dec 2011 13:27 |
Reporter: | Esben Mose Hansen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 14.14 Distrib 5.1.58, for deb | OS: | Linux (Debian sid) |
Assigned to: | CPU Architecture: | Any | |
Tags: | lock IX X |
[8 Dec 2011 11:12]
Esben Mose Hansen
[8 Dec 2011 11:33]
Valeriy Kravchuk
Sorry, but you misread that manual page. What is important is that IX lock is set on table level, so you have to check locks at the same level for conflicts, not row (lower level) locks. Table clearly shows that IX lock from one transaction is compatible with IX lock from other transaction (on the same table). Only X or S lock at table level is not compatible (think LOCK TABLE ...). Manual clearly says: "Thus, intention locks do not block anything except full table requests (for example, LOCK TABLES ... WRITE). The main purpose of IX and IS locks is to show that someone is locking a row, or going to lock a row in the table."
[8 Dec 2011 13:22]
Esben Mose Hansen
Thanks for explaining :) And sorry, the manual is not clear at all, and could be improved in several ways. 1. Nowhere on the page is the *table* lock type X or S mentioned. The closest is that the sentence "To make locking at multiple granularity levels practical, *additional* types of locks called intention locks are used." (emphasis mime). It would be much easier to read if all the table level locks (X, S, IX, IS) were listed at some point. 2. It is not mentioned anywhere that conflicts are on the same level only, except for the bit your mentioned that could be interpreted sort of that way. Much better if the sentence I quoted were written as "A lock is granted to a requesting transaction if it is compatible with *all* existing locks *on the same granularity level*, but not if it conflicts with *any* existing locks *on the same granularity level*." Emphasis are my insertions. It might be better without the "but.." part, but that is a detail. 3. Finally, it would still be a huge improvement if it was explained how exactly to see gap locks vs. row locks in the output of show engine innodb status on the following pages. Again, thank you for the explanation and I hope the manual change I have suggested could save you from being bothered in the future. I actually had 2 people beside me read the manual page, and neither could explain the observed behavior.
[8 Dec 2011 13:27]
Esben Mose Hansen
One last improvement: It would be good if all the granularity levels were listed (ROW level, TABLE level). That would eliminate any confusion whether e.g. gap locks are on the same level as ROW locks, or on a separate granularity levels).