From 05c9821a7c4047ecd976fec448aa07cc7de0e9b7 Mon Sep 17 00:00:00 2001 From: vasil Date: Tue, 8 May 2007 07:20:02 +0000 Subject: [PATCH] Fix Bug#25078 by always letting the replication thread on the slave server to enter InnoDB. This can be made further customizable by the user if we introduce a new config parameter. This will wait until config parameters can be easily added. Approved by: Marko --- handler/ha_innodb.cc | 17 +++++++++++++++++ include/ha_prototypes.h | 16 ++++++++++++++++ srv/srv0srv.c | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index a4399dd7680..f8affc02ea0 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -407,6 +407,23 @@ static SHOW_VAR innodb_status_variables[]= { /* General functions */ +/********************************************************************** +Returns true if the thread is the replication thread on the slave +server. Used in srv_conc_enter_innodb() to determine if the thread +should be allowed to enter InnoDB - the replication thread is treated +differently than other threads. Also used in +srv_conc_force_exit_innodb(). */ + +extern "C" +ibool +thd_is_replication_slave_thread( +/*============================*/ + /* out: true if thd is the replication thread */ + void* thd) /* in: thread handle (THD*) */ +{ + return((ibool)(((THD*)thd)->slave_thread)); +} + /********************************************************************** Save some CPU by testing the value of srv_thread_concurrency in inline functions. */ diff --git a/include/ha_prototypes.h b/include/ha_prototypes.h index 2d27034fdfe..a796e83fbce 100644 --- a/include/ha_prototypes.h +++ b/include/ha_prototypes.h @@ -1,6 +1,9 @@ #ifndef HA_INNODB_PROTOTYPES_H #define HA_INNODB_PROTOTYPES_H +#include "univ.i" /* ulint, uint */ +#include "m_ctype.h" /* CHARSET_INFO */ + /* Prototypes for global functions in ha_innodb.cc that are called by InnoDB's C-code. */ @@ -19,4 +22,17 @@ innobase_convert_string( CHARSET_INFO* from_cs, uint* errors); +/********************************************************************** +Returns true if the thread is the replication thread on the slave +server. Used in srv_conc_enter_innodb() to determine if the thread +should be allowed to enter InnoDB - the replication thread is treated +differently than other threads. Also used in +srv_conc_force_exit_innodb(). */ + +ibool +thd_is_replication_slave_thread( +/*============================*/ + /* out: true if thd is the replication thread */ + void* thd); /* in: thread handle (THD*) */ + #endif diff --git a/srv/srv0srv.c b/srv/srv0srv.c index 29796a964d9..5a94bfa4e00 100644 --- a/srv/srv0srv.c +++ b/srv/srv0srv.c @@ -47,6 +47,7 @@ Created 10/8/1995 Heikki Tuuri #include "dict0boot.h" #include "srv0start.h" #include "row0mysql.h" +#include "ha_prototypes.h" /* This is set to TRUE if the MySQL user has set it in MySQL; currently affects only FOREIGN KEY definition parsing */ @@ -987,6 +988,17 @@ srv_conc_enter_innodb( srv_conc_slot_t* slot = NULL; ulint i; + if (trx->mysql_thd != NULL + && thd_is_replication_slave_thread(trx->mysql_thd)) { + + /* TODO Do something more interesting (based on a config + parameter). Some users what to give the replication + thread very low priority, see http://bugs.mysq.com/25078 + This can be done by introducing + innodb_replication_delay(ms) config parameter */ + return; + } + /* If trx has 'free tickets' to enter the engine left, then use one such ticket */ @@ -1162,6 +1174,12 @@ srv_conc_force_exit_innodb( return; } + if (trx->mysql_thd != NULL + && thd_is_replication_slave_thread(trx->mysql_thd)) { + + return; + } + if (trx->declared_to_be_inside_innodb == FALSE) { return;