MDEV-5829: STOP SLAVE resets global status variables

Reason for the bug was an optimization for higher connect speed where we moved when global status was updated,
but forgot to update states when slave thread dies.
Fixed by adding thd->add_status_to_global() before deleting slave thread's thd.


mysys/my_delete.c:
  Added missing newline
sql/mysqld.cc:
  Use add_status_to_global()
sql/slave.cc:
  Added missing add_status_to_global()
sql/sql_class.cc:
  Use add_status_to_global()
sql/sql_class.h:
  Simplify adding local status to global by adding add_status_to_global()
This commit is contained in:
Michael Widenius 2014-03-14 16:29:23 +02:00
commit dd13db6f4a
7 changed files with 32 additions and 11 deletions

View file

@ -695,6 +695,11 @@ typedef struct system_status_var
#define last_system_status_var questions
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
STATUS_VAR *dec_var);
void mark_transaction_to_rollback(THD *thd, bool all);
#ifdef MYSQL_SERVER
@ -3103,6 +3108,14 @@ public:
void wait_for_wakeup_ready();
/* Wake this thread up from wait_for_wakeup_ready(). */
void signal_wakeup_ready();
void add_status_to_global()
{
mysql_mutex_lock(&LOCK_status);
add_to_status(&global_status_var, &status_var);
mysql_mutex_unlock(&LOCK_status);
}
private:
/** The current internal error handler for this thread, or NULL. */
@ -4145,10 +4158,6 @@ public:
*/
#define CF_SKIP_QUESTIONS (1U << 1)
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
STATUS_VAR *dec_var);
void mark_transaction_to_rollback(THD *thd, bool all);
/* Inline functions */