Commit 111acb72 authored by Jan Lindström's avatar Jan Lindström

MDEV-9359: encryption.create_or_replace fails sporadically in buildbot:...

MDEV-9359: encryption.create_or_replace fails sporadically in buildbot: failing assertion: mutex->magic_n == MUTEX_MAGIC_N

Make sure that encryption threads mutex is initialized before starting
encryption threads.
parent 56e0de04
......@@ -2294,6 +2294,10 @@ fil_crypt_set_thread_cnt(
/*=====================*/
uint new_cnt) /*!< in: New key rotation thread count */
{
if (!fil_crypt_threads_inited) {
fil_crypt_threads_init();
}
if (new_cnt > srv_n_fil_crypt_threads) {
uint add = new_cnt - srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = new_cnt;
......@@ -2358,15 +2362,18 @@ void
fil_crypt_threads_init()
/*====================*/
{
fil_crypt_event = os_event_create();
fil_crypt_threads_event = os_event_create();
mutex_create(fil_crypt_threads_mutex_key,
&fil_crypt_threads_mutex, SYNC_NO_ORDER_CHECK);
uint cnt = srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = 0;
fil_crypt_set_thread_cnt(cnt);
fil_crypt_threads_inited = true;
ut_ad(mutex_own(&fil_system->mutex));
if (!fil_crypt_threads_inited) {
fil_crypt_event = os_event_create();
fil_crypt_threads_event = os_event_create();
mutex_create(fil_crypt_threads_mutex_key,
&fil_crypt_threads_mutex, SYNC_NO_ORDER_CHECK);
uint cnt = srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = 0;
fil_crypt_threads_inited = true;
fil_crypt_set_thread_cnt(cnt);
}
}
/*********************************************************************
......@@ -2389,6 +2396,7 @@ fil_crypt_threads_cleanup()
{
os_event_free(fil_crypt_event);
os_event_free(fil_crypt_threads_event);
fil_crypt_threads_inited = false;
}
/*********************************************************************
......
......@@ -2984,7 +2984,9 @@ innobase_start_or_create_for_mysql(void)
fts_optimize_init();
/* Create thread(s) that handles key rotation */
fil_system_enter();
fil_crypt_threads_init();
fil_system_exit();
/* Create the log scrub thread */
if (srv_scrub_log)
......
......@@ -422,7 +422,13 @@ mutex_validate(
const ib_mutex_t* mutex) /*!< in: mutex */
{
ut_a(mutex);
ut_a(mutex->magic_n == MUTEX_MAGIC_N);
if (mutex->magic_n != MUTEX_MAGIC_N) {
ib_logf(IB_LOG_LEVEL_ERROR,
"Mutex %p not initialized file %s line %lu.",
mutex, mutex->cfile_name, mutex->cline);
}
ut_ad(mutex->magic_n == MUTEX_MAGIC_N);
return(TRUE);
}
......
......@@ -2294,6 +2294,10 @@ fil_crypt_set_thread_cnt(
/*=====================*/
uint new_cnt) /*!< in: New key rotation thread count */
{
if (!fil_crypt_threads_inited) {
fil_crypt_threads_init();
}
if (new_cnt > srv_n_fil_crypt_threads) {
uint add = new_cnt - srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = new_cnt;
......@@ -2358,15 +2362,18 @@ void
fil_crypt_threads_init()
/*====================*/
{
fil_crypt_event = os_event_create();
fil_crypt_threads_event = os_event_create();
mutex_create(fil_crypt_threads_mutex_key,
&fil_crypt_threads_mutex, SYNC_NO_ORDER_CHECK);
uint cnt = srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = 0;
fil_crypt_set_thread_cnt(cnt);
fil_crypt_threads_inited = true;
ut_ad(mutex_own(&fil_system->mutex));
if (!fil_crypt_threads_inited) {
fil_crypt_event = os_event_create();
fil_crypt_threads_event = os_event_create();
mutex_create(fil_crypt_threads_mutex_key,
&fil_crypt_threads_mutex, SYNC_NO_ORDER_CHECK);
uint cnt = srv_n_fil_crypt_threads;
srv_n_fil_crypt_threads = 0;
fil_crypt_threads_inited = true;
fil_crypt_set_thread_cnt(cnt);
}
}
/*********************************************************************
......@@ -2389,6 +2396,7 @@ fil_crypt_threads_cleanup()
{
os_event_free(fil_crypt_event);
os_event_free(fil_crypt_threads_event);
fil_crypt_threads_inited = false;
}
/*********************************************************************
......
......@@ -3076,7 +3076,9 @@ innobase_start_or_create_for_mysql(void)
fts_optimize_init();
/* Create thread(s) that handles key rotation */
fil_system_enter();
fil_crypt_threads_init();
fil_system_exit();
/* Create the log scrub thread */
if (srv_scrub_log)
......
......@@ -482,7 +482,13 @@ mutex_validate(
const ib_mutex_t* mutex) /*!< in: mutex */
{
ut_a(mutex);
ut_a(mutex->magic_n == MUTEX_MAGIC_N);
if (mutex->magic_n != MUTEX_MAGIC_N) {
ib_logf(IB_LOG_LEVEL_ERROR,
"Mutex %p not initialized file %s line %lu.",
mutex, mutex->cfile_name, mutex->cline);
}
ut_ad(mutex->magic_n == MUTEX_MAGIC_N);
return(TRUE);
}
......
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