diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-01-18 16:56:16 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-01-18 16:56:16 +0200 |
commit | 6373ec3ec74515574f8a08535ed0d090b13d9122 (patch) | |
tree | d2a7393afdf99b7b609a9c911e16a121c862b403 /sql | |
parent | e709eb9bf712006d070767629518f827cd2f6bed (diff) | |
parent | d595a91bc6bfb9f9c38bf91738b2a563d80c62e0 (diff) | |
download | mariadb-git-6373ec3ec74515574f8a08535ed0d090b13d9122.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_thd.cc | 49 | ||||
-rw-r--r-- | sql/wsrep_thd.h | 2 | ||||
-rw-r--r-- | sql/wsrep_var.cc | 10 |
4 files changed, 46 insertions, 17 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0d47aee9882..87a45a1baed 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14554,7 +14554,7 @@ static int compare_fields_by_table_order(Item *field1, Item_field *f2= (Item_field *) field2_real; if (f1->used_tables() & OUTER_REF_TABLE_BIT) { - outer_ref= -1; + outer_ref= 1; cmp= -1; } if (f2->used_tables() & OUTER_REF_TABLE_BIT) diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index e251df956c4..8674366a71f 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -415,29 +415,46 @@ static void wsrep_replication_process(THD *thd) DBUG_VOID_RETURN; } -static bool create_wsrep_THD(wsrep_thread_args* args) +static bool create_wsrep_THD(wsrep_thread_args* args, bool thread_count_lock) { - mysql_mutex_lock(&LOCK_thread_count); + if (!thread_count_lock) + mysql_mutex_lock(&LOCK_thread_count); + ulong old_wsrep_running_threads= wsrep_running_threads; + DBUG_ASSERT(args->thread_type == WSREP_APPLIER_THREAD || args->thread_type == WSREP_ROLLBACKER_THREAD); + bool res= mysql_thread_create(args->thread_type == WSREP_APPLIER_THREAD ? key_wsrep_applier : key_wsrep_rollbacker, &args->thread_id, &connection_attrib, start_wsrep_THD, (void*)args); + + if (res) + { + WSREP_ERROR("Can't create wsrep thread"); + } + /* if starting a thread on server startup, wait until the this thread's THD is fully initialized (otherwise a THD initialization code might try to access a partially initialized server data structure - MDEV-8208). */ if (!mysqld_server_initialized) + { while (old_wsrep_running_threads == wsrep_running_threads) + { mysql_cond_wait(&COND_thread_count, &LOCK_thread_count); - mysql_mutex_unlock(&LOCK_thread_count); + } + } + + if (!thread_count_lock) + mysql_mutex_unlock(&LOCK_thread_count); + return res; } -void wsrep_create_appliers(long threads) +bool wsrep_create_appliers(long threads, bool thread_count_lock) { if (!wsrep_connected) { @@ -449,26 +466,32 @@ void wsrep_create_appliers(long threads) "connection at '%s'", wsrep_cluster_address); assert(0); } - return; + return false; } - long wsrep_threads=0; + long wsrep_threads= 0; + while (wsrep_threads++ < threads) { wsrep_thread_args* arg; - if((arg = (wsrep_thread_args*)my_malloc(sizeof(wsrep_thread_args), MYF(0))) == NULL) { + + if((arg= (wsrep_thread_args*)my_malloc(sizeof(wsrep_thread_args), MYF(0))) == NULL) + { WSREP_ERROR("Can't allocate memory for wsrep replication thread %ld\n", wsrep_threads); assert(0); } - arg->thread_type = WSREP_APPLIER_THREAD; - arg->processor = wsrep_replication_process; + arg->thread_type= WSREP_APPLIER_THREAD; + arg->processor= wsrep_replication_process; - if (create_wsrep_THD(arg)) { - WSREP_WARN("Can't create thread to manage wsrep replication"); + if (create_wsrep_THD(arg, thread_count_lock)) + { + WSREP_ERROR("Can't create thread to manage wsrep replication"); my_free(arg); - return; + return true; } } + + return false; } static void wsrep_rollback_process(THD *thd) @@ -564,7 +587,7 @@ void wsrep_create_rollbacker() arg->processor = wsrep_rollback_process; /* create rollbacker */ - if (create_wsrep_THD(arg)) { + if (create_wsrep_THD(arg, false)) { WSREP_WARN("Can't create thread to manage wsrep rollback"); my_free(arg); return; diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h index 6ce14a4eb0e..8d928014518 100644 --- a/sql/wsrep_thd.h +++ b/sql/wsrep_thd.h @@ -26,7 +26,7 @@ int wsrep_show_bf_aborts (THD *thd, SHOW_VAR *var, char *buff, enum enum_var_type scope); void wsrep_client_rollback(THD *thd); void wsrep_replay_transaction(THD *thd); -void wsrep_create_appliers(long threads); +bool wsrep_create_appliers(long threads, bool thread_count_lock=false); void wsrep_create_rollbacker(); int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr, diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 258c00b9f88..f18dc565329 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -602,16 +602,22 @@ static void wsrep_slave_count_change_update () bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) { + mysql_mutex_lock(&LOCK_thread_count); + bool res= false; + wsrep_slave_count_change_update(); if (wsrep_slave_count_change > 0) { WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads); - wsrep_create_appliers(wsrep_slave_count_change); + res= wsrep_create_appliers(wsrep_slave_count_change, true); WSREP_DEBUG("Running %lu applier threads", wsrep_running_applier_threads); wsrep_slave_count_change = 0; } - return false; + + mysql_mutex_unlock(&LOCK_thread_count); + + return res; } bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var) |