diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 30e3648576a..612ff4c6e54 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -476,6 +476,14 @@ enum srv_thread_type srv_get_thread_type(void); /*=====================*/ /*********************************************************************//** +Check whether thread type has reserved a slot. +@return slot number or UNDEFINED if not found*/ +UNIV_INTERN +ulint +srv_thread_has_reserved_slot( +/*=========================*/ + enum srv_thread_type type); /*!< in: thread type to check */ +/*********************************************************************//** Sets the info describing an i/o thread current state. */ UNIV_INTERN void diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 6e9fc6ab1c7..1c57d6960d0 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -982,6 +982,37 @@ srv_get_thread_type(void) return(type); } +/*********************************************************************//** +Check whether thread type has reserved a slot. Return the first slot that +is found. This works because we currently have only 1 thread of each type. +@return slot number or ULINT_UNDEFINED if not found*/ +UNIV_INTERN +ulint +srv_thread_has_reserved_slot( +/*=========================*/ + enum srv_thread_type type) /*!< in: thread type to check */ +{ + ulint i; + ulint slot_no = ULINT_UNDEFINED; + + mutex_enter(&kernel_mutex); + + for (i = 0; i < OS_THREAD_MAX_N; i++) { + srv_slot_t* slot; + + slot = srv_table_get_nth_slot(i); + + if (slot->in_use && slot->type == type) { + slot_no = i; + break; + } + } + + mutex_exit(&kernel_mutex); + + return(slot_no); +} + /*********************************************************************//** Initializes the server. */ UNIV_INTERN diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 0e121b58d81..acb448a1a67 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -1833,6 +1833,24 @@ innobase_start_or_create_for_mysql(void) os_thread_create(&srv_purge_thread, NULL, NULL); } + /* Wait for the purge and master thread to startup. */ + + while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + if (srv_thread_has_reserved_slot(SRV_MASTER) == ULINT_UNDEFINED + || (srv_n_purge_threads == 1 + && srv_thread_has_reserved_slot(SRV_WORKER) + == ULINT_UNDEFINED)) { + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: " + "Waiting for the background threads to " + "start\n"); + os_thread_sleep(1000000); + } else { + break; + } + } + #ifdef UNIV_DEBUG /* buf_debug_prints = TRUE; */ #endif /* UNIV_DEBUG */