diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-03-04 15:28:22 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-03-04 15:28:22 +0200 |
commit | e648b0bf22562d62e12184b0b8620fb6b96c0d80 (patch) | |
tree | 465ff2aa355ed209c5bc704f3941d84613e0897d | |
parent | 3008039ab9b491fb9cae0631b0ccf33ad343cecf (diff) | |
download | mariadb-git-bb-10.0-slave.tar.gz |
MDEV-7578 :Slave is ~10x slower to execute set of statements compared to master when using RBRbb-10.0-slave
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_slave_thread(user_thd) and
thd_sql_command(user_thd) == SQLCOM_END.
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 8 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3941de9e205..4415ce66683 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6785,8 +6785,12 @@ ha_innobase::innobase_lock_autoinc(void) 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 this is (single/multi) row INSERTs/REPLACEs, or + slave thread executing Write_rows_log_event */ if (thd_sql_command(user_thd) == SQLCOM_INSERT - || thd_sql_command(user_thd) == SQLCOM_REPLACE) { + || thd_sql_command(user_thd) == SQLCOM_REPLACE + || (thd_slave_thread(user_thd) && thd_sql_command(user_thd) == SQLCOM_END)) { dict_table_t* ib_table = prebuilt->table; /* Acquire the AUTOINC mutex. */ @@ -6798,6 +6802,8 @@ ha_innobase::innobase_lock_autoinc(void) /* Release the mutex to avoid deadlocks. */ dict_table_autoinc_unlock(ib_table); } else { + /* Do not fall back to old style autoinc + locking */ break; } } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 078795786fc..4a6a6a01357 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -7342,8 +7342,12 @@ ha_innobase::innobase_lock_autoinc(void) 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 this is (single/multi) row INSERTs/REPLACEs, or + slave thread executing Write_rows_log_event */ if (thd_sql_command(user_thd) == SQLCOM_INSERT - || thd_sql_command(user_thd) == SQLCOM_REPLACE) { + || thd_sql_command(user_thd) == SQLCOM_REPLACE + || (thd_slave_thread(user_thd) && thd_sql_command(user_thd) == SQLCOM_END)) { dict_table_t* ib_table = prebuilt->table; /* Acquire the AUTOINC mutex. */ @@ -7355,6 +7359,8 @@ ha_innobase::innobase_lock_autoinc(void) /* Release the mutex to avoid deadlocks. */ dict_table_autoinc_unlock(ib_table); } else { + /* Do not fall back to old style autoinc + locking */ break; } } |