From 1322371fb21d6efb85181e2518d1a6cf198bd95d Mon Sep 17 00:00:00 2001 From: "sven@riska.(none)" <> Date: Tue, 11 Mar 2008 14:42:54 +0100 Subject: [PATCH] BUG#31024: STOP SLAVE does not stop attempted connect()s Problem: if the IO slave thread is attempting to connect, STOP SLAVE waits for the attempt to finish. It may take a long time. Fix: don't wait, stop the slave immediately. --- sql/slave.cc | 15 ++++++++++++++- sql/sql_repl.h | 6 ------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index d4d0655f366..5488b3c312a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -699,7 +699,20 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock, while (*slave_running) // Should always be true { DBUG_PRINT("loop", ("killing slave thread")); - KICK_SLAVE(thd); + + pthread_mutex_lock(&thd->LOCK_delete); +#ifndef DONT_USE_THR_ALARM + /* + Error codes from pthread_kill are: + EINVAL: invalid signal number (can't happen) + ESRCH: thread already killed (can happen, should be ignored) + */ + IF_DBUG(int err= ) pthread_kill(thd->real_id, thr_client_alarm); + DBUG_ASSERT(err != EINVAL); +#endif + thd->awake(THD::NOT_KILLED); + pthread_mutex_unlock(&thd->LOCK_delete); + /* There is a small chance that slave thread might miss the first alarm. To protect againts it, resend the signal until it reacts diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 1fbc6eb30cf..cf400218cc2 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -35,12 +35,6 @@ extern I_List binlog_do_db, binlog_ignore_db; extern int max_binlog_dump_events; extern my_bool opt_sporadic_binlog_dump_fail; -#define KICK_SLAVE(thd) do { \ - pthread_mutex_lock(&(thd)->LOCK_delete); \ - (thd)->awake(THD::NOT_KILLED); \ - pthread_mutex_unlock(&(thd)->LOCK_delete); \ - } while(0) - int start_slave(THD* thd, MASTER_INFO* mi, bool net_report); int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report); bool change_master(THD* thd, MASTER_INFO* mi);