[MDEV-24853] Duplicate key may be generated during cluster configuration change Created: 2021-02-12  Updated: 2021-03-08  Resolved: 2021-03-08

Status: Closed
Project: MariaDB Server
Component/s: Galera, Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10, 10.6.0

Type: Bug Priority: Critical
Reporter: Julius Goryavsky Assignee: Julius Goryavsky
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks

 Description   

The fix for MENT-1023 needs to be migrated to the CS version:
-------------
Incorrect processing of an auto-incrementing field during applying transactions results in a duplicate key being created. This is due to the fact that at the beginning of the write_row() and update_row() functions, the values ​​of the auto-increment parameters are used, which are read from the parameters of the current thread, but further along the code other values are used, which are read from global variables (when applying a transaction). This can happen when the cluster configuration has changed while applying a transaction (in high_priority_service mode for Galera 4). Further during IST processing duplicating key is detected, and processing of the DB_DUPLICATE_KEY return code (inside innodb, in the write_row() handler) results in a call to wsrep_thd_self_abort().



 Comments   
Comment by Marko Mäkelä [ 2021-02-23 ]

Please request a new review once all tests pass. A quick peek at a few results suggests that the test innodb.innodb-autoinc is failing with a result difference on all platforms.

I think that we must be very conservative regarding auto_increment value generation and that this must be extensively tested with all values of innodb_autoinc_lock_mode. I did not see any added test case.

Comment by Marko Mäkelä [ 2021-03-04 ]

The InnoDB change looks fine to me. Other than that, this seems to just be removing some Galera-specific AUTO_INCREMENT handling. I ran the mtr tests for the change on 10.2, 10.3 and 10.6. The result change in innodb.innodb-autoinc looks acceptable.

I would suggest to test how a Galera cluster behaves when the cluster is partly running this fix, on both Galera 3 (10.2 or 10.3) and Galera 4 (10.4 or later).

Comment by Julius Goryavsky [ 2021-03-08 ]

Fixed, commit for 10.2 branch: https://github.com/MariaDB/server/commit/7345d37141899ad0575814465a1b90d87aa4f363
Reference commit for merging with 10.4-10.6 branches: https://github.com/MariaDB/server/commit/151ed4bce4f39f21bf7c36afff74e6ddecc071b4

Generated at Thu Feb 08 09:33:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.