| Bug #106113 | Contribution by Tencent: insert on duplicate key cause 1032 replication error in | ||
|---|---|---|---|
| Submitted: | 8 Jan 2022 6:52 | Modified: | 8 Jan 2022 7:39 |
| Reporter: | Xiaodong Huang (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Replication | Severity: | S2 (Serious) |
| Version: | 8.0.27, 5.7.36 | OS: | Any |
| Assigned to: | CPU Architecture: | x86 | |
| Tags: | Contribution | ||
[8 Jan 2022 6:52]
Xiaodong Huang
[8 Jan 2022 6:55]
Xiaodong Huang
The patch: (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: 0001-Fix-1032-replication-error-cased-by-inserting-on-dup.patch (application/octet-stream, text), 2.70 KiB.
[8 Jan 2022 6:58]
Xiaodong Huang
The solution is apply logs in the order in which it appear in the event.
[8 Jan 2022 7:39]
MySQL Verification Team
Hello Xiaodong, Thank you for the report and contribution. regards, Umesh
[23 Apr 12:21]
Arthur Schreiber
We also encountered this bug in production, both on the latest versions of MySQL 8.0 as well as 8.4, and I believe this bug also affects the just released MySQL 9.7. We've prepared an alternative fix, which is a bit more straightforward than the patch provided by Xiaodong. Instead of looping a second time over the entries in the bucket trying to find the one with the minimum `bi_start` value, we simply keep track of the "best" entry (where the best entry has the lowest `bi_start` value) on the first iteration through the bucket. This change ensures replicas apply updates in source order for tables that don't have an index suitable for the `INDEX_SCAN` method. Note that this fixes BUG#105802 and BUG#106918, and the patch also includes test cases that cover the cases reported in all three bug reports. I will attach the patch for this shortly.
[23 Apr 12:23]
Arthur Schreiber
patch and test cases
Attachment: bug-106113-8.4.patch (application/octet-stream, text), 15.37 KiB.
