diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-07-11 07:13:58 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-07-15 10:17:07 +0300 |
commit | ec49976e383ae42650fb99e7477c072550d89876 (patch) | |
tree | 2169aaffae1594462b4184bec250378d2cec2bae /sql/wsrep_thd.cc | |
parent | b3bd51c9929509d23648c11fbe87b5a4760e13e4 (diff) | |
download | mariadb-git-ec49976e383ae42650fb99e7477c072550d89876.tar.gz |
MDEV-19746: Galera test failures because of wsrep_slave_threads identification
Problem was that tests select INFORMATION_SCHEMA.PROCESSLIST processes
from user system user and empty state. Thus, there is not clear
state for slave threads.
Changes:
- Added new status variables that store current amount of applier threads
(wsrep_applier_thread_count) and rollbacker threads
(wsrep_rollbacker_thread_count). This will make clear how many slave threads
of certain type there is.
- Added THD state "wsrep applier idle" when applier slave thread is
waiting for work. This makes finding slave/applier threads easier.
- Added force-restart option for mtr to always restart servers between tests
to avoid race on start of the test
- Added wait_condition_with_debug to wait until the passed statement returns
true, or the operation times out. If operation times out, the additional error
statement will be executed
Changes to be committed:
new file: mysql-test/include/force_restart.inc
new file: mysql-test/include/wait_condition_with_debug.inc
modified: mysql-test/mysql-test-run.pl
modified: mysql-test/suite/galera/disabled.def
modified: mysql-test/suite/galera/r/MW-336.result
modified: mysql-test/suite/galera/r/galera_kill_applier.result
modified: mysql-test/suite/galera/r/galera_var_slave_threads.result
new file: mysql-test/suite/galera/t/MW-336.cnf
modified: mysql-test/suite/galera/t/MW-336.test
modified: mysql-test/suite/galera/t/galera_kill_applier.test
modified: mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test
modified: mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test
modified: mysql-test/suite/galera/t/galera_var_slave_threads.test
modified: mysql-test/suite/wsrep/disabled.def
modified: mysql-test/suite/wsrep/r/variables.result
modified: mysql-test/suite/wsrep/t/variables.test
modified: sql/mysqld.cc
modified: sql/wsrep_mysqld.cc
modified: sql/wsrep_mysqld.h
modified: sql/wsrep_thd.cc
modified: sql/wsrep_var.cc
Diffstat (limited to 'sql/wsrep_thd.cc')
-rw-r--r-- | sql/wsrep_thd.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 1d00a64c972..31b6622d30c 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -360,6 +360,7 @@ static void wsrep_replication_process(THD *thd) thd->variables.option_bits|= OPTION_BEGIN; thd->server_status|= SERVER_STATUS_IN_TRANS; + thd_proc_info(thd, "wsrep applier idle"); rcode = wsrep->recv(wsrep, (void *)thd); DBUG_PRINT("wsrep",("wsrep_repl returned: %d", rcode)); @@ -415,13 +416,12 @@ static void wsrep_replication_process(THD *thd) DBUG_VOID_RETURN; } -static bool create_wsrep_THD(wsrep_thd_processor_fun processor) +static bool create_wsrep_THD(wsrep_thread_args* args) { ulong old_wsrep_running_threads= wsrep_running_threads; - pthread_t unused; mysql_mutex_lock(&LOCK_thread_count); - bool res= pthread_create(&unused, &connection_attrib, start_wsrep_THD, - (void*)processor); + bool res= pthread_create(&args->thread_id, &connection_attrib, start_wsrep_THD, + (void*)args); /* if starting a thread on server startup, wait until the this thread's THD is fully initialized (otherwise a THD initialization code might @@ -451,8 +451,20 @@ void wsrep_create_appliers(long threads) long wsrep_threads=0; while (wsrep_threads++ < threads) { - if (create_wsrep_THD(wsrep_replication_process)) + wsrep_thread_args* arg; + 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; + + if (create_wsrep_THD(arg)) { WSREP_WARN("Can't create thread to manage wsrep replication"); + my_free(arg); + return; + } } } @@ -539,9 +551,21 @@ void wsrep_create_rollbacker() { if (wsrep_provider && strcasecmp(wsrep_provider, "none")) { + wsrep_thread_args* arg; + if((arg = (wsrep_thread_args*)my_malloc(sizeof(wsrep_thread_args), MYF(0))) == NULL) { + WSREP_ERROR("Can't allocate memory for wsrep rollbacker thread\n"); + assert(0); + } + + arg->thread_type = WSREP_ROLLBACKER_THREAD; + arg->processor = wsrep_rollback_process; + /* create rollbacker */ - if (create_wsrep_THD(wsrep_rollback_process)) + if (create_wsrep_THD(arg)) { WSREP_WARN("Can't create thread to manage wsrep rollback"); + my_free(arg); + return; + } } } |