[Commits] e648b0b: MDEV-7578 :Slave is ~10x slower to execute set of statements compared to master when using RBR

Jan Lindström jan.lindstrom at mariadb.com
Wed Mar 4 15:33:19 EET 2015


revision-id: e648b0bf22562d62e12184b0b8620fb6b96c0d80
parent(s): 3008039ab9b491fb9cae0631b0ccf33ad343cecf
committer: Jan Lindström
branch nick: 10.0-git
timestamp: 2015-03-04 15:28:22 +0200
message:

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_slave_thread(user_thd) and
thd_sql_command(user_thd) == SQLCOM_END.

---
 storage/innobase/handler/ha_innodb.cc | 8 +++++++-
 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 3941de9..4415ce6 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 0787957..4a6a6a0 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;
 			}
 		}


More information about the commits mailing list