summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2020-02-04 09:00:36 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2020-02-04 11:14:21 +0200
commit46386661a2311cabd7bac914c44b1af0b4746e07 (patch)
tree90317a3db130183e3e4e9c808b8c1a9a1e4b89a7
parent93278ee8ad0798a042bd8141b646ff3a17a7383d (diff)
downloadmariadb-git-46386661a2311cabd7bac914c44b1af0b4746e07.tar.gz
MDEV-20625 : MariaDB asserting when enabling wsrep_onbb-10.4-MDEV-20625
We need to release global system variables mutex before doing wsrep_init to avoid race with next show status and we need to save wsrep_on value as it is changed on wsrep_init. Added test case.
-rw-r--r--mysql-test/suite/wsrep/r/MDEV-20625.result3
-rw-r--r--mysql-test/suite/wsrep/t/MDEV-20625.test1
-rw-r--r--sql/wsrep_var.cc21
3 files changed, 14 insertions, 11 deletions
diff --git a/mysql-test/suite/wsrep/r/MDEV-20625.result b/mysql-test/suite/wsrep/r/MDEV-20625.result
index cf48f163b77..3e2b621c8f9 100644
--- a/mysql-test/suite/wsrep/r/MDEV-20625.result
+++ b/mysql-test/suite/wsrep/r/MDEV-20625.result
@@ -1,4 +1,5 @@
SET GLOBAL wsrep_on=ON;
SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';
Variable_name Value
-wsrep_cluster_size 1
+wsrep_cluster_size 0
+SET GLOBAL wsrep_on=OFF;
diff --git a/mysql-test/suite/wsrep/t/MDEV-20625.test b/mysql-test/suite/wsrep/t/MDEV-20625.test
index 09092b454c3..2a537fe432e 100644
--- a/mysql-test/suite/wsrep/t/MDEV-20625.test
+++ b/mysql-test/suite/wsrep/t/MDEV-20625.test
@@ -7,3 +7,4 @@
SET GLOBAL wsrep_on=ON;
SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';
+SET GLOBAL wsrep_on=OFF;
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index e5bd3d0416d..8ec251d8915 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -97,28 +97,29 @@ struct handlerton* innodb_hton_ptr __attribute__((weak));
bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type)
{
if (var_type == OPT_GLOBAL) {
+ my_bool saved_wsrep_on= global_system_variables.wsrep_on;
+
thd->variables.wsrep_on= global_system_variables.wsrep_on;
// If wsrep has not been inited we need to do it now
if (global_system_variables.wsrep_on && wsrep_provider && !wsrep_inited)
{
- bool rcode= false;
char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider
//when fails
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+
if (wsrep_init())
{
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, my_error, "wsrep_init failed");
- rcode= true;
+ //rcode= true;
}
- free(tmp);
- // we sure don't want to use old address with new provider
- wsrep_cluster_address_init(NULL);
- wsrep_provider_options_init(NULL);
- if (!rcode)
- refresh_provider_options();
+ free(tmp);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
+
+ thd->variables.wsrep_on= global_system_variables.wsrep_on= saved_wsrep_on;
}
return false;
@@ -342,11 +343,11 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
WSREP_DEBUG("wsrep_provider_update: %s", wsrep_provider);
- /* stop replication is heavy operation, and includes closing all client
+ /* stop replication is heavy operation, and includes closing all client
connections. Closing clients may need to get LOCK_global_system_variables
at least in MariaDB.
- Note: releasing LOCK_global_system_variables may cause race condition, if
+ Note: releasing LOCK_global_system_variables may cause race condition, if
there can be several concurrent clients changing wsrep_provider
*/
mysql_mutex_unlock(&LOCK_global_system_variables);