diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-03-05 12:05:59 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-03-05 12:05:59 +0200 |
commit | f66fbe8ce0ff4ffcd6a6c185f9b3d25bd9f67f8d (patch) | |
tree | 0381c1b4ab73dd85f9becce3d05be191d187bfa2 | |
parent | 45b6edb158f8101d641f550179ee15df363f686f (diff) | |
download | mariadb-git-f66fbe8ce0ff4ffcd6a6c185f9b3d25bd9f67f8d.tar.gz |
MDEV-7578 :Slave is ~10x slower to execute set of statements compared to master when using RBR
Analysis: On master when executing (single/multi) row INSERTs/REPLACEs
InnoDB fallback to old style autoinc locks (table locks)
only if another transaction has already acquired the AUTOINC lock.
Instead on slave as we are executing log_events and sql_command
is not correctly set, InnoDB does not use new style autoinc
locks when it could.
Fix: Use new style autoinc locks also when
thd_sql_command(user_thd) == SQLCOM_END i.e. this is RBR event.
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 17 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 17 |
2 files changed, 22 insertions, 12 deletions
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; } } |