Bug #69946 | Shared read lock on SELECT in transaction on VARCHAR column with UK constraint | ||
---|---|---|---|
Submitted: | 7 Aug 2013 7:13 | Modified: | 11 Feb 2017 2:38 |
Reporter: | Daniel Coteanu | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Cluster: Documentation | Severity: | S2 (Serious) |
Version: | 5.6.11-ndb-7.3.2-cluster | OS: | Linux (RHEL 6.2) |
Assigned to: | CPU Architecture: | Any | |
Tags: | shared read lock |
[7 Aug 2013 7:13]
Daniel Coteanu
[7 Aug 2013 10:16]
MySQL Verification Team
Hello Daniel, Thank you for the bug report and the test case. Verified as described on recent MySQL-5.6.11 ndb-7.3.2 Thanks, Umesh
[7 Aug 2013 14:35]
Daniel Coteanu
Change the severity level.
[9 Aug 2013 7:06]
Santo Leto
Hi, Regarding your comment "But in our case the column is not TEXT or BLOB, but VARCHAR." Please note that this has nothing to do with the fact that the column is VARCHAR. This is related only to the fact that the data in the first select are accessed using a UNIQUE KEY, instead of a PRIMARY KEY. As you wrote in the bug description, the lock does not occur if you use a PK instead of a UK Note that even if you have a PK, like in this table CREATE TABLE `test_uk2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 if you use the UK to filter the data you will incur in the lock as well, but you will not get it if you will use the PK. This is a know limitation that needs to be documented better in our documentation Possible workarounds: 1. Can I ask you if you are using the unique constraint just as a constraint (in order to avoid duplicates), or if you really need to use it to lookup rows efficiently? if you are using it just to avoid duplicates, then you can workaround the problem by using the PK to lookup the row (use of FORCE INDEX can help) 2. If you need to use the UK to efficiently lookup rows, then another option is to do this: i) Transaction 1, lookup unique index to get row primary key value, commit. ii) Transaction 2, Use primary key value to read/write row The first transaction is short lived, so will not block updates for long. The second transaction does not use the unique key for access, so does not block updates. The downside here is that the row with primary key value retrieved in transaction 1 may have been modified by the time Transaction 2 reads it - this is what the lock upgrade avoids.
[11 Feb 2017 2:37]
Jon Stephens
This is not a bug, but is rather intentional. It thus becomes a documentation issue, and as such is a duplicate of Docs BUG#80471.
[11 Feb 2017 2:38]
Jon Stephens
Closed as duplicate. See previous comment.
[11 Feb 2017 2:48]
Jon Stephens
Sorry for the long hiatus. There was some confusion due to the fact that this remained a code bug when it should have been moved to the Docs queue--I'll try to get this issue resolved in the documentation within the next few days. Thanks!
[17 Feb 2017 12:22]
Jon Stephens
Note: This is actually not a bug, but rather a known issue that was documented quite a long time ago. See BUG#80471.