diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 1054db6cee4..9e44707b1a2 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -93,6 +93,7 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size __attribute__((unused))) { + DBUG_ENTER("reset_root_defaults"); DBUG_ASSERT(alloc_root_inited(mem_root)); mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE; @@ -114,7 +115,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, { /* We found a suitable block, no need to do anything else */ mem_root->pre_alloc= mem; - return; + DBUG_VOID_RETURN; } if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size) { @@ -142,6 +143,8 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, else #endif mem_root->pre_alloc= 0; + + DBUG_VOID_RETURN; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 415f6c3d617..b42d586d748 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4604,7 +4604,17 @@ a file name for --log-bin-index option", opt_binlog_index_name); { if (tmp->wsrep_applier == true) { + /* + Set THR_THD to temporally point to this THD to register all the + variables that allocates memory for this THD. + */ + THD *current_thd_saved= current_thd; + my_pthread_setspecific_ptr(THR_THD, tmp); + tmp->init_for_queries(); + + /* Restore current_thd. */ + my_pthread_setspecific_ptr(THR_THD, current_thd_saved); } } mysql_mutex_unlock(&LOCK_thread_count); @@ -4912,7 +4922,7 @@ pthread_handler_t start_wsrep_THD(void *arg) thd->proc_info= 0; thd->command= COM_SLEEP; - if (plugins_are_initialized) + if (wsrep_creating_startup_threads == 0) { thd->init_for_queries(); }