mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
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
This commit is contained in:
parent
91fc720350
commit
dead1dc42a
3 changed files with 57 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue