Bug #96578 `Insert on duplicate key update` updates the wrong row
| Submitted: | 16 Aug 2019 22:08 | Modified: | 4 Feb 2020 19:16 |
|---|---|---|---|
| Reporter: | Zhicheng Zhu | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: DML | Severity: | S2 (Serious) |
| Version: | 8.0.16, 5.7.27, 8.0.17 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[16 Aug 2019 22:08]
Zhicheng Zhu
[17 Aug 2019 6:59]
MySQL Verification Team
Hello Zhicheng Zhu, Thank you for the report. regards, Umesh
[17 Aug 2019 7:00]
MySQL Verification Team
Test results - 8.0.17, 5.7.27
Attachment: 96578_5.6.45_5.7.27_8.0.17.results (application/octet-stream, text), 200.80 KiB.
[20 Aug 2019 16:17]
Zhicheng Zhu
Hello Umesh, Thanks for investigating this! I just looked at the result file. Just curious have you setup the DEBUT_SYNC point? This is actual the key step to create a consistent repro
[22 Aug 2019 11:12]
MySQL Verification Team
Hi Zhicheng Zhu, I haven't changed anything from your repro case while running on debug build. While simulating on release build, as suggested by you - removed the Assertion `next_insert_id >= auto_inc_interval_for_cur_row.minimum()' in handler::update_auto_increment and commented out DEBUG_SYNC references from the mtr test case. regards, Umesh
[22 Aug 2019 16:07]
Zhicheng Zhu
Hello Umesh, I guess there might be some confusion in my comments. To mimic release, just remove Assertion `next_insert_id >= auto_inc_interval_for_cur_row.minimum()', but keep DEBUG_SYNC. Keeping the DEBUG_SYNC is the key, otherwise you need to kept running two queries concurrently for multiple times to repo the issue, which isn't very convenient. **Please don't comment out the DEBUG_SYNC** Thanks, Zhicheng
[23 Aug 2019 6:57]
MySQL Verification Team
Hi Zhicheng Zhu, Thank you for the clarification, removed assertion but left the DEBUG_SYNC**. Please note that this again requires debug build as release builds will complain "ERROR 1193 (HY000): Unknown system variable 'DEBUG_SYNC'". Joining the test results shortly which confirms the reported issue now. regards, Umesh
[23 Aug 2019 6:57]
MySQL Verification Team
Test results - 8.0.17
Attachment: 96578_8.0.17.results (application/octet-stream, text), 341.48 KiB.
[23 Aug 2019 15:26]
Zhicheng Zhu
Hello Umesh, Yes. "ERROR 1193 (HY000): Unknown system variable 'DEBUG_SYNC'" is expected if you run it under release mode. This is why we have to **remove assert in Debug mode to mimic the behavior in release mode** :-) Let me know if you need anything Thanks, Zhicheng
[23 Aug 2019 15:26]
Zhicheng Zhu
Hello Umesh, Yes. "ERROR 1193 (HY000): Unknown system variable 'DEBUG_SYNC'" is expected if you run it under release mode. This is why we have to **remove assert in Debug mode to mimic the behavior in release mode** :-) Let me know if you need anything Thanks, Zhicheng
[26 Nov 2019 15:35]
Paul DuBois
Posted by developer: Fixed in 5.6.47, 5.7.29, 8.0.19. With multiple sessions executing concurrent INSERT ... ON DUPLICATE KEY UPDATE statements into a table with an AUTO_INCREMENT column but not specifying the AUTO_INCREMENT value, inserts could fail with a unique index violation.
[26 Nov 2019 19:31]
Zhicheng Zhu
Thanks for fixing this! Is there a way I can look at this fix and back port this to our system?
[4 Feb 2020 18:00]
Satya Bodapati
https://github.com/mysql/mysql-server/commit/cbd87693248cb4d2a217a8f1c13108e3eca1ecff
[4 Feb 2020 19:16]
Zhicheng Zhu
Awesome! Thanks for fixing this!
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.044 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.