summaryrefslogtreecommitdiff
path: root/sql/wsrep_thd.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-01-18 16:56:16 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-01-18 16:56:16 +0200
commit6373ec3ec74515574f8a08535ed0d090b13d9122 (patch)
treed2a7393afdf99b7b609a9c911e16a121c862b403 /sql/wsrep_thd.cc
parente709eb9bf712006d070767629518f827cd2f6bed (diff)
parentd595a91bc6bfb9f9c38bf91738b2a563d80c62e0 (diff)
downloadmariadb-git-6373ec3ec74515574f8a08535ed0d090b13d9122.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql/wsrep_thd.cc')
-rw-r--r--sql/wsrep_thd.cc49
1 files changed, 36 insertions, 13 deletions
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;