Details
-
New Feature
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
By default, InnoDB uses excessive statement-level locking on operations that involve AUTO_INCREMENT columns. This was only needed to work around a bug in statement-level replication.
As noted in MDEV-19577, we can improve statement-level replication so that it will acquire an exclusive InnoDB table lock to protect the AUTO_INCREMENT values. In this way, with the default settings log_bin=OFF or binlog_format=MIXED, no performance penalty will occur.
By escalating affected operations in binlog_format=STATEMENT to statement-scope table-level locking, we remove the need for InnoDB auto-increment locks. As part of this task, those locks will still be preserved; users may still set innodb_autoinc_lock_mode to 0 or 1 in order to allow the old-style locking to be used.
The parameter innodb_autoinc_lock_mode and the InnoDB auto-increment locks would be removed in a future major release.
Attachments
Issue Links
- is blocked by
-
MDEV-19577 Replication does not work with innodb_autoinc_lock_mode=2
-
- Closed
-
- relates to
-
MDEV-10170 Misleading "Statements writing to a table with an auto-increment column after selecting from another table are unsafe" on DELETE ... SELECT
-
- Confirmed
-
-
MDEV-29416 Auto_Increment function broken
-
- Open
-
In the end, I introduced a new lock mode LOCK_AUTO_INC_X that has a statement scope like LOCK_AUTO_INC but will conflict with any lock. This lock will be acquired when statement-level replication needs to reserve AUTO_INCREMENT values and we are running in the (now default) innodb_autoinc_lock_mode=2. This lock will be released at the end of the statement, just like LOCK_AUTO_INC always was.
When we remove the configuration parameter innodb_autoinc_lock_mode in a later major release, we would also remove LOCK_AUTO_INC but not the newer LOCK_AUTO_INC_X. Both could be removed if binlog_format=STATEMENT was extended to include the allocated AUTO_INCREMENT values.