Commit 0908a049 authored by Jan Lindström's avatar Jan Lindström

MDEV-25389 : Assertion `!is_thread_specific || (mysqld_server_initialized &&...

MDEV-25389 : Assertion `!is_thread_specific || (mysqld_server_initialized && thd)' failed in void my_malloc_size_cb_func(long long int, my_bool)

If wsrep slave thread creation fails for some reason we need to handle
this error correctly and set actual running slave threads accordingly.
parent e8acec89
connection node_2;
connection node_1;
connection node_2;
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
SET GLOBAL wsrep_slave_threads=2;
ERROR HY000: Incorrect arguments to SET
SELECT @@wsrep_slave_threads;
@@wsrep_slave_threads
1
SET GLOBAL debug_dbug='';
SET GLOBAL wsrep_slave_threads=1;
SELECT @@wsrep_slave_threads;
@@wsrep_slave_threads
1
--source include/galera_cluster.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--connection node_2
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
--error ER_WRONG_ARGUMENTS
SET GLOBAL wsrep_slave_threads=2;
SELECT @@wsrep_slave_threads;
SET GLOBAL debug_dbug='';
SET GLOBAL wsrep_slave_threads=1;
SELECT @@wsrep_slave_threads;
......@@ -126,6 +126,7 @@ ulong wsrep_trx_fragment_unit= WSREP_FRAG_BYTES;
ulong wsrep_SR_store_type= WSREP_SR_STORE_TABLE;
uint wsrep_ignore_apply_errors= 0;
std::atomic <bool> wsrep_thread_create_failed;
/*
* End configuration options
......@@ -2940,7 +2941,9 @@ void* start_wsrep_THD(void *arg)
{
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
// This will signal error to wsrep_slave_threads_update
wsrep_thread_create_failed.store(true, std::memory_order_relaxed);
WSREP_DEBUG("start_wsrep_THD: init_new_connection_thread failed");
goto error;
}
......
/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
/* Copyright 2008-2022 Codership Oy <http://www.codership.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -88,6 +88,7 @@ extern ulong wsrep_running_rollbacker_threads;
extern bool wsrep_new_cluster;
extern bool wsrep_gtid_mode;
extern uint32 wsrep_gtid_domain_id;
extern std::atomic <bool > wsrep_thread_create_failed;
enum enum_wsrep_reject_types {
WSREP_REJECT_NONE, /* nothing rejected */
......
/* Copyright (C) 2013-2021 Codership Oy <info@codership.com>
/* Copyright (C) 2013-2022 Codership Oy <info@codership.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
/* Copyright 2008-2022 Codership Oy <http://www.codership.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -753,12 +753,30 @@ bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type)
if (wsrep_slave_count_change > 0)
{
WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads);
wsrep_thread_create_failed.store(false, std::memory_order_relaxed);
res= wsrep_create_appliers(wsrep_slave_count_change, true);
mysql_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
// Thread creation and execution is asyncronous, therefore we need
// wait them to be started or error produced
while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads &&
!wsrep_thread_create_failed.load(std::memory_order_relaxed))
{
my_sleep(1000);
}
mysql_mutex_lock(&LOCK_global_system_variables);
if (wsrep_thread_create_failed.load(std::memory_order_relaxed)) {
wsrep_slave_threads= wsrep_running_applier_threads;
return true;
}
WSREP_DEBUG("Running %lu applier threads", wsrep_running_applier_threads);
wsrep_slave_count_change = 0;
}
mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
else
mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
return res;
}
......
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