summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2021-01-20 09:38:20 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2021-01-25 14:59:19 +0200
commit05e89393addef4f917183e692e6f0ba2d20734eb (patch)
tree00f21736b08088f0869cc59e0d72f016b0e233c2
parent46234f03c82e1deb20ddcc41a802d763959cc18e (diff)
downloadmariadb-git-bb-10.6-MDEV-24509.tar.gz
MDEV-24509 : Warning: Memory not freed: 56 on SET @@global.wsrep_sst_authbb-10.6-MDEV-24509
It seems that memory is not freed when updated value is NULL or when wsrep is not initialized before shutdown.
-rw-r--r--mysql-test/suite/galera/r/galera_var_sst_auth.result16
-rw-r--r--mysql-test/suite/galera/t/galera_var_sst_auth.test29
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/wsrep_mysqld.cc2
-rw-r--r--sql/wsrep_sst.cc10
5 files changed, 52 insertions, 11 deletions
diff --git a/mysql-test/suite/galera/r/galera_var_sst_auth.result b/mysql-test/suite/galera/r/galera_var_sst_auth.result
index 6a5683e2633..53b8443705a 100644
--- a/mysql-test/suite/galera/r/galera_var_sst_auth.result
+++ b/mysql-test/suite/galera/r/galera_var_sst_auth.result
@@ -1,8 +1,5 @@
connection node_2;
connection node_1;
-#
-# MDEV-10492: Assertion failure on shutdown when wsrep_sst_auth set in config
-#
SELECT @@global.wsrep_sst_auth;
@@global.wsrep_sst_auth
********
@@ -10,5 +7,14 @@ SET @@global.wsrep_sst_auth='foo:bar';
SELECT @@global.wsrep_sst_auth;
@@global.wsrep_sst_auth
********
-disconnect node_2;
-disconnect node_1;
+connection node_2;
+SET @@global.wsrep_sst_auth= 'abcdefghijklmnopqrstuvwxyz';
+SELECT @@global.wsrep_sst_auth;
+@@global.wsrep_sst_auth
+********
+Shutdown node_2
+connection node_1;
+connection node_2;
+SELECT @@global.wsrep_sst_auth;
+@@global.wsrep_sst_auth
+********
diff --git a/mysql-test/suite/galera/t/galera_var_sst_auth.test b/mysql-test/suite/galera/t/galera_var_sst_auth.test
index 5c9b3f5a61e..ad7f46620ad 100644
--- a/mysql-test/suite/galera/t/galera_var_sst_auth.test
+++ b/mysql-test/suite/galera/t/galera_var_sst_auth.test
@@ -1,12 +1,33 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
---echo #
---echo # MDEV-10492: Assertion failure on shutdown when wsrep_sst_auth set in config
---echo #
+#
+# MDEV-10492: Assertion failure on shutdown when wsrep_sst_auth set in config
+#
SELECT @@global.wsrep_sst_auth;
SET @@global.wsrep_sst_auth='foo:bar';
SELECT @@global.wsrep_sst_auth;
---source include/galera_end.inc
+#
+# MDEV-24509 Warning: Memory not freed: 56 on SET @@global.wsrep_sst_auth
+#
+--connection node_2
+SET @@global.wsrep_sst_auth= 'abcdefghijklmnopqrstuvwxyz';
+SELECT @@global.wsrep_sst_auth;
+--echo Shutdown node_2
+--source include/shutdown_mysqld.inc
+
+# On node_1, verify that the node has left the cluster.
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# Restart node_2
+--connection node_2
+--source include/start_mysqld.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+SELECT @@global.wsrep_sst_auth;
+
+
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d0477b0effd..95d459c4ddc 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1772,10 +1772,11 @@ static void close_connections(void)
server_threads.iterate(warn_threads_active_after_phase_1);
#ifdef WITH_WSREP
+ WSREP_DEBUG("Shutdown wsrep_inited %d wsrep_sst_auth %p", wsrep_inited, wsrep_sst_auth);
+
if (wsrep_inited == 1)
- {
wsrep_deinit(true);
- }
+ wsrep_sst_auth_free();
#endif
/* All threads has now been aborted */
DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)",
@@ -1889,6 +1890,7 @@ extern "C" void unireg_abort(int exit_code)
wsrep_deinit(true);
wsrep_deinit_server();
}
+ wsrep_sst_auth_free();
#endif // WITH_WSREP
clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 8118822d595..8f3f7cc3f79 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -996,6 +996,8 @@ void wsrep_deinit(bool free_options)
free(p);
}
+ WSREP_DEBUG("wsrep_deinit free_options %d wsrep_sst_auth %p", free_options, wsrep_sst_auth);
+
if (free_options)
{
wsrep_sst_auth_free();
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index c78a9359704..b9c47546642 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -256,6 +256,7 @@ static bool sst_auth_real_set (const char* value)
if (v)
{
+ WSREP_DEBUG("wsrep_sst_auth_update: sst_auth %p auth_real %p", wsrep_sst_auth, sst_auth_real);
// set sst_auth_real
if (sst_auth_real) { my_free((void *) sst_auth_real); }
sst_auth_real= v;
@@ -266,6 +267,13 @@ static bool sst_auth_real_set (const char* value)
if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); }
wsrep_sst_auth= my_strdup(PSI_INSTRUMENT_ME, WSREP_SST_AUTH_MASK, MYF(0));
}
+ else
+ {
+ if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); }
+ wsrep_sst_auth= NULL;
+ }
+
+ WSREP_DEBUG("wsrep_sst_auth_update: sst_auth_end %p auth_real %p", wsrep_sst_auth, sst_auth_real);
return 0;
}
return 1;
@@ -273,6 +281,7 @@ static bool sst_auth_real_set (const char* value)
void wsrep_sst_auth_free()
{
+ WSREP_DEBUG("wsrep_sst_auth_free: sst_auth %p auth_real %p", wsrep_sst_auth, sst_auth_real);
if (wsrep_sst_auth) { my_free((void *) wsrep_sst_auth); }
if (sst_auth_real) { my_free((void *) sst_auth_real); }
wsrep_sst_auth= NULL;
@@ -281,6 +290,7 @@ void wsrep_sst_auth_free()
bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type)
{
+ WSREP_DEBUG("wsrep_sst_auth_update: sst_auth %p auth_real %p", wsrep_sst_auth, sst_auth_real);
return sst_auth_real_set (wsrep_sst_auth);
}