Bug #76927 | Duplicate UK values in READ-COMMITTED (again) | ||
---|---|---|---|
Submitted: | 4 May 2015 12:09 | Modified: | 17 Aug 2015 13:38 |
Reporter: | Alexey Kopytov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 5.1, 5.5, 5.6, 5.7, 8.0 | OS: | Any |
Assigned to: | Kevin Lewis | CPU Architecture: | Any |
[4 May 2015 12:09]
Alexey Kopytov
[4 May 2015 12:42]
MySQL Verification Team
fwiw, 5.8.0-debug shows this in the error log: Version: '5.8.0-m17-debug' socket: '' port: 3306 MySQL Community Server (GPL) 2015-05-04T12:39:06.072253Z 3 [ERROR] InnoDB: duplicate key in `a` of table `test`.`t1`: TUPLE (info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000000)}, COMPACT RECORD(info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000001)} 2015-05-04T12:39:06.072753Z 4 [ERROR] InnoDB: duplicate key in `a` of table `test`.`t1`: TUPLE (info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000000)}, COMPACT RECORD(info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000001)} 2015-05-04T12:39:06.073253Z 2 [ERROR] InnoDB: duplicate key in `a` of table `test`.`t1`: TUPLE (info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000000)}, COMPACT RECORD(info_bits=0, 2 fields): {[4] (0x00000000),[4] (0x00000001)}
[4 May 2015 12:47]
MySQL Verification Team
Verified on 5.6, 5.7, 5.8!
[4 May 2015 13:42]
MySQL Verification Team
Also affects 5.5.43!
[4 May 2015 16:47]
MySQL Verification Team
Verified on 5.1.73 - builtin!
[4 May 2015 18:11]
Alexey Kopytov
Shane, Thanks for verifying it against older versions. It looks like the problem has been there for a very long time. Re: extra output in the error log for 5.8.0-debug, I guess it comes from CHECK TABLE. I see similar messages in 5.6 release builds.
[5 May 2015 5:03]
MySQL Verification Team
5.0.96 was NOT affected, after running test overnight.
[25 May 2015 17:33]
Alexey Kopytov
MTR test case
Attachment: bug76927.test (application/octet-stream, text), 2.00 KiB.
[25 May 2015 17:34]
Alexey Kopytov
The MTR test case requires a new DEBUG_SYNC point. Patch against current 5.6 git HEAD: diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index e31b447..f35d36b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2709,6 +2709,8 @@ row_ins_sec_index_entry_low( goto func_exit; } + DEBUG_SYNC_C("row_ins_sec_index_entry_dup_locks_created"); + /* We did not find a duplicate and we have now locked with s-locks the necessary records to prevent any insertion of a duplicate by another
[25 May 2015 17:45]
Alexey Kopytov
The problem is with lock_rec_inherit_to_gap(() assuming that only S-locks can be set by a consistency constraint and thus, only those kind of locks should be inherited in the gap mode when an index record is removed. However, REPLACE, LOAD DATA REPLACE and INSERT ON DUPLICATE KEY UPDATE set exclusive record locks. So when a record is removed by a purge, all record locks acquired by in-progress concurrent statements of those types are lost which leads to a UK constraint violation. This is the scenario reproduced by the MTR case.
[18 Jul 2015 11:47]
OCA Admin
Contribution submitted via Github - Bug #76927: Duplicate UK values in READ-COMMITTED (again) (*) Contribution by Alexey Kopytov (Github akopytov, mysql-server/pull/23#issuecomment-122257474): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: git_patch_40130846.txt (text/plain), 7.02 KiB.
[17 Aug 2015 13:38]
Daniel Price
Posted by developer: Fixed as of the upcoming 5.5.46, 5.6.27, 5.7.9, 5.8.0 release, and here's the changelog entry: In READ COMMITTED mode, a REPLACE operation on a unique secondary index resulted in a constraint violation. Thanks to Alexey Kopytov for the patch. Thank you for the bug report.
[18 Jun 2016 21:26]
Omer Barnir
Posted by developer: Reported version value updated to reflect release name change from 5.8 to 8.0