Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Won't Fix
-
10.3.11, 10.2.19
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.
MDEV-17073 disabled the changes except when statement-based replication is being used. Even with statement-based replication, the locking could be replaced with additional logging: extending the replication event with information on which index records were locked when the duplicate was detected. (Note that the dict_table_t::indexes may be sorted differently on master and slave, especially if CREATE UNIQUE INDEX was executed with ALGORITHM=INPLACE.
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.
In mixed mode, we prefer security over speed and in this case statements using ON DUPLICATE KEY UPDATE should use binary logging to ensure it works even if the slave is using different storage engines or different index definitions than the master.
Attachments
Issue Links
- relates to
-
MDEV-17614 INSERT on dup key update is replication unsafe
- Closed
-
MDEV-16232 Use fewer mini-transactions
- Stalled
-
MDEV-17073 INSERT…ON DUPLICATE KEY UPDATE became more deadlock-prone
- Closed
-
MDEV-17604 rpl information service
- Open
-
MDEV-18141 Unexpected ER_KEY_NOT_FOUND upon REPLACE into table with foreign key with statement binary logging
- Closed
-
MDEV-19342 Merge new release of InnoDB 5.7.26 to 10.2
- Closed
-
MDEV-19462 Deadlock with vBulletin server and replication
- Closed