[MDEV-19577] Replication does not work with innodb_autoinc_lock_mode=2 Created: 2019-05-23 Updated: 2022-04-01 Resolved: 2022-03-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication, Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8 |
| Fix Version/s: | 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Vladislav Lesin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption, race, upstream | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
In
He wants to deprecate and remove the innodb_autoinc_lock_mode system variable, after setting it to 2 by default (MDEV-27844). For that to happen, the dependency on this variable would have to be removed for replication and binary logging. We have two bugs in replication:
|
| Comments |
| Comment by Andrei Elkin [ 2019-05-24 ] | |||||||||||||||
|
The statement binlog format can be extended to contain auto-increment intervals.
| |||||||||||||||
| Comment by Andrei Elkin [ 2020-04-09 ] | |||||||||||||||
|
The following commit may be relevant: | |||||||||||||||
| Comment by Marko Mäkelä [ 2022-01-25 ] | |||||||||||||||
|
monty, you claimed some time ago that the auto-increment locks are unnecessary. It looks like you could be right. With the following simple patch, no mtr tests failed, apart from those that test this default value:
Can you confirm that this is on the right track? If this really is so simple, the next steps would be to remove all code related to auto-increment locking, to deprecate and ignore this parameter, and of course, to run some replication stress tests. | |||||||||||||||
| Comment by Michael Widenius [ 2022-01-25 ] | |||||||||||||||
|
Yes, as far as I know, you only need the variable for statement or mixed base logging (when mixed as run as statement, but this can trivially be checked for the statement). 1) For binary logging, all rows are fully logged and thus there is no reason to lock the innodb increment. This will ensure that the slave will get the right data. For doing efficient statement based logging with increments, then we would need save the used auto-increment intervals as part of the statement based logging, like Andrei suggested. For binary logging this should not be needed. | |||||||||||||||
| Comment by Marko Mäkelä [ 2022-01-26 ] | |||||||||||||||
|
monty, thank you for the clarification. I have understood that with the default BINLOG_FORMAT=MIXED, statement-level logging will be used unless THD::current_stmt_binlog_format has been changed to BINLOG_FORMAT_ROW. There is some predicate for checking if an operation requires row-level logging. The uniqueness of AUTO_INCREMENT values is guaranteed by the dict_table_t::autoinc_mutex. If I understood correctly, the statement-level LOCK_AUTO_INC are needed for the BINLOG_FORMAT=STATEMENT format, to ensure that each statement will get a contiguous sequence of AUTO_INCREMENT values. Unfortunately, this locking will be needed in all operations that involve AUTO_INCREMENT values if there is any chance that any concurrent connection may use statement-level logging for AUTO_INCREMENT operations. That is a high price to pay for something that is rarely used (if my understanding is correct). We would seem to have to do something about AUTO_INCREMENT operations in BINLOG_FORMAT=STATEMENT mode. I can think of two options:
Obviously, disallowing would be easier. But it probably is unacceptable, because BINLOG_FORMAT=STATEMENT could still be widely used. We might need some storage engine API change for implementing the binlog-driven AUTO_INCREMENT locking, unless it is somehow doable with the existing member functions. | |||||||||||||||
| Comment by Andrei Elkin [ 2022-02-03 ] | |||||||||||||||
|
As a remark to | |||||||||||||||
| Comment by Andrei Elkin [ 2022-02-03 ] | |||||||||||||||
|
(A) As the STATEMENT binlog format will be undoubtedly required for a long time and
As it looks there's nothing more requiring Engine changes for (B). OLD->NEW requirement constrains us to maintain @@ innodb_autoinc_lock_mode = 1 execution mode on slave, until the current INSERT Query_log_event format (with just one initial value) gets out of support. So we'd probably have to maintain the current Innodb mode=1 behavior until the relieve moment. | |||||||||||||||
| Comment by Vladislav Lesin [ 2022-03-10 ] | |||||||||||||||
|
The following is implemented:
|