Commit 8aab002f authored by Sunny Bains's avatar Sunny Bains

Fix Bug #58653 - Sporadic crash due to assertion failure 0 == space->n_pending_flushes

      
Check whether the master and purge thread are active after creating them. Do
not proceed until both threads have started. We do this by checking whether a
slot has been reserved by both the respective threads.
      
Add srv_thread_has_reserved_slot() returns slot no or ULINT_UNDEFINED.
      
rb://536 Approved by Jimmy
parent 8ee4c16d
...@@ -476,6 +476,14 @@ enum srv_thread_type ...@@ -476,6 +476,14 @@ enum srv_thread_type
srv_get_thread_type(void); 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. */ Sets the info describing an i/o thread current state. */
UNIV_INTERN UNIV_INTERN
void void
......
...@@ -982,6 +982,37 @@ srv_get_thread_type(void) ...@@ -982,6 +982,37 @@ srv_get_thread_type(void)
return(type); 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. */ Initializes the server. */
UNIV_INTERN UNIV_INTERN
......
...@@ -1833,6 +1833,24 @@ innobase_start_or_create_for_mysql(void) ...@@ -1833,6 +1833,24 @@ innobase_start_or_create_for_mysql(void)
os_thread_create(&srv_purge_thread, NULL, NULL); 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 #ifdef UNIV_DEBUG
/* buf_debug_prints = TRUE; */ /* buf_debug_prints = TRUE; */
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment