From 34860f74e4dbb9c7d619acdf5501879b580fd17c Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Mon, 10 May 2010 13:17:17 +1000 Subject: [PATCH] Fix bug#53499 - purge thread is active during shutdown, assert buf/buf0buf.c line 4115. Check that all background threads are suspended or shutdown instead of just checking for the master thread. rb://333 --- storage/innobase/include/srv0srv.h | 8 ++++---- storage/innobase/log/log0log.c | 14 +++++++------- storage/innobase/srv/srv0srv.c | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index e5f019e8ce3..75af697e046 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -639,12 +639,12 @@ srv_que_task_enqueue_low( que_thr_t* thr); /*!< in: query thread */ /**********************************************************************//** -Check whether the master thread is active. -@return FALSE is it is not active. */ +Check whether any background thread is active. +@return FALSE if all are are suspended or have exited. */ UNIV_INTERN ibool -srv_is_master_thread_active(void); -/*==============================*/ +srv_is_any_background_thread_active(void); +/*======================================*/ /** Status variables to be passed to MySQL */ struct export_var_struct{ diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c index 65985aed588..386f9630baa 100644 --- a/storage/innobase/log/log0log.c +++ b/storage/innobase/log/log0log.c @@ -3133,9 +3133,9 @@ loop: mutex_exit(&kernel_mutex); - /* Check that the master thread is suspended */ + /* Check that the background threads are suspended */ - if (srv_is_master_thread_active()) { + if (srv_is_any_background_thread_active()) { goto loop; } @@ -3196,10 +3196,10 @@ loop: mutex_exit(&(log_sys->mutex)); - /* Check that the master thread has stayed suspended */ - if (srv_is_master_thread_active()) { + /* Check that the background threads stay suspended */ + if (srv_is_any_background_thread_active()) { fprintf(stderr, - "InnoDB: Warning: the master thread woke up" + "InnoDB: Warning: some background thread woke up" " during shutdown\n"); goto loop; @@ -3221,7 +3221,7 @@ loop: srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE; /* Make some checks that the server really is quiet */ - ut_a(!srv_is_master_thread_active()); + ut_a(!srv_is_any_background_thread_active()); ut_a(buf_all_freed()); ut_a(lsn == log_sys->lsn); @@ -3243,7 +3243,7 @@ loop: fil_close_all_files(); /* Make some checks that the server really is quiet */ - ut_a(!srv_is_master_thread_active()); + ut_a(!srv_is_any_background_thread_active()); ut_a(buf_all_freed()); ut_a(lsn == log_sys->lsn); diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 55251f81435..11448e4e166 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -2559,18 +2559,24 @@ srv_inc_activity_count(void) } /**********************************************************************//** -Check whether the master thread is active. -@return FALSE is it is not active. */ +Check whether any background thread is active. +@return FALSE if all are are suspended or have exited. */ UNIV_INTERN ibool -srv_is_master_thread_active(void) -/*=============================*/ +srv_is_any_background_thread_active(void) +/*=====================================*/ { - ibool ret; + ulint i; + ibool ret = FALSE; srv_sys_mutex_enter(); - ret = srv_sys->n_threads_active[SRV_MASTER] != 0; + for (i = SRV_COM; i <= SRV_MASTER; ++i) { + if (srv_sys->n_threads_active[i] != 0) { + ret = TRUE; + break; + } + } srv_sys_mutex_exit();