diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fe68cc9ac85..95dfc9dfc5a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5104,12 +5104,15 @@ ha_innobase::innobase_lock_autoinc(void) break; case AUTOINC_NEW_STYLE_LOCKING: - /* For simple (single/multi) row INSERTs, we fallback to the - old style only if another transaction has already acquired - the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT - etc. type of statement. */ + /* For simple (single/multi) row INSERTs/REPLACEs and RBR + events, we fallback to the old style only if another + transaction has already acquired the AUTOINC lock on + behalf of a LOAD FILE or INSERT ... SELECT etc. type of + statement. */ if (thd_sql_command(user_thd) == SQLCOM_INSERT - || thd_sql_command(user_thd) == SQLCOM_REPLACE) { + || thd_sql_command(user_thd) == SQLCOM_REPLACE + || thd_sql_command(user_thd) == SQLCOM_END // RBR event + ) { dict_table_t* table = prebuilt->table; /* Acquire the AUTOINC mutex. */ @@ -5118,9 +5121,11 @@ ha_innobase::innobase_lock_autoinc(void) /* We need to check that another transaction isn't already holding the AUTOINC lock on the table. */ if (table->n_waiting_or_granted_auto_inc_locks) { - /* Release the mutex to avoid deadlocks. */ + /* Release the mutex to avoid deadlocks and + fall back to old style locking. */ dict_table_autoinc_unlock(table); } else { + /* Do not fall back to old style locking. */ break; } } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 235caeb5067..2fd56013139 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -6064,12 +6064,15 @@ ha_innobase::innobase_lock_autoinc(void) break; case AUTOINC_NEW_STYLE_LOCKING: - /* For simple (single/multi) row INSERTs, we fallback to the - old style only if another transaction has already acquired - the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT - etc. type of statement. */ + /* For simple (single/multi) row INSERTs/REPLACEs and RBR + events, we fallback to the old style only if another + transaction has already acquired the AUTOINC lock on + behalf of a LOAD FILE or INSERT ... SELECT etc. type of + statement. */ if (thd_sql_command(user_thd) == SQLCOM_INSERT - || thd_sql_command(user_thd) == SQLCOM_REPLACE) { + || thd_sql_command(user_thd) == SQLCOM_REPLACE + || thd_sql_command(user_thd) == SQLCOM_END // RBR event + ) { dict_table_t* table = prebuilt->table; /* Acquire the AUTOINC mutex. */ @@ -6078,9 +6081,11 @@ ha_innobase::innobase_lock_autoinc(void) /* We need to check that another transaction isn't already holding the AUTOINC lock on the table. */ if (table->n_waiting_or_granted_auto_inc_locks) { - /* Release the mutex to avoid deadlocks. */ + /* Release the mutex to avoid deadlocks and + fall back to old style locking. */ dict_table_autoinc_unlock(table); } else { + /* Do not fall back to old style locking. */ break; } }