[MDEV-17603] Allow statement-based replication for REPLACE and INSERT…ON DUPLICATE KEY UPDATE Created: 2018-11-02 Updated: 2023-04-24 Resolved: 2020-06-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.3.11, 10.2.19 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Marko Mäkelä | Assignee: | Sachin Setiya (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | affects-tests, lock, performance, replication, upstream-fixed | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
MySQL 5.7.4 changed the behaviour of REPLACE and INSERT…ON DUPLICATE KEY UPDATE in the InnoDB storage engine. Upon encountering a duplicate key, it would no longer directly fall back to UPDATE, but instead it would proceed to acquire an exclusive lock on every index record for the row on which the INSERT failed. The extra locking was motivated by a public bug report: MySQL Bug#50413 insert on duplicate key update sometimes writes binlog position incorrectly (Oracle internal BUG#11758237). The fix was followed up by a couple of regression fixes. For one MariaDB user, reverting these changes significantly reduced the deadlock rate of INSERT…ON DUPLICATE KEY UPDATE.
The documentation at https://mariadb.com/kb/en/binary-log-formats/ states that even if one is using Statement based logging, it's assumed that the tables are the same on master and slave and both are using the same storage engine. In this case Statement logging should work. |
| Comments |
| Comment by Marko Mäkelä [ 2018-11-03 ] | |||||||||||||||||||||
|
Given that binlog_format=MIXED is the default, it could be simplest to refuse statement-based replication for the unsafe statements (instead of trying to make them safe by extra locking), and gracefully fall back to row-based replication. Revert-InnoDB-SBR-changes.patch | |||||||||||||||||||||
| Comment by Andrei Elkin [ 2018-11-05 ] | |||||||||||||||||||||
|
The scope of the current patch is to "save" STATEMENT binlog format | |||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-03-06 ] | |||||||||||||||||||||
|
Fixing this could end up fixing | |||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-25 ] | |||||||||||||||||||||
|
It turns out that upstream reverted the problematic fix and implemented a better fix in MySQL 5.7.26. I plan to essentially revert | |||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-26 ] | |||||||||||||||||||||
|
I reverted MDEV-17073 and the upstream change and implemented and tested a simplified version of what appeared in MySQL 5.7.26. Neither our test innodb.auto_increment_dup,log-bin nor the upstream test innodb.iodku would pass with those changes. (OK, I missed follow-up fixes to their test case.) What happens in innodb.auto_increment_dup,log-bin is that the newly converted explicit lock for the record will be released when that record is deleted by the rollback moments later. The idea of converting implicit locks to explicit on rollback is somewhat expensive. One motivation of MDEV-16232 is to reduce the amount of explicit locks by holding page latches across some handler API calls. Ideally, this problem would be fixed by changing something in replication, perhaps simply by refusing statement-based replication for these operations. | |||||||||||||||||||||
| Comment by Andrei Elkin [ 2019-06-04 ] | |||||||||||||||||||||
|
The priority is lowered to focus on | |||||||||||||||||||||
| Comment by Sachin Setiya (Inactive) [ 2019-06-08 ] | |||||||||||||||||||||
|
Test Case:-
| |||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-08-12 ] | |||||||||||||||||||||
|
Now that | |||||||||||||||||||||
| Comment by Sachin Setiya (Inactive) [ 2020-06-01 ] | |||||||||||||||||||||
|
After discussion with Elkin and monty , It is decided that this will no longer be fixed, User are advised to user mixed binlog_format , Since it is most optimized and takes care of these issues |