diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2013-11-29 13:03:00 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2013-11-29 13:03:00 -0500 |
commit | e4f5e49cd6de1c9e4899a6e6f5c6666434e02437 (patch) | |
tree | 64a37e2c832a63447f0e87e32c716099c453a17b | |
parent | 6271c06a73ce1065ac53a554e42a0049bf77eb53 (diff) | |
download | mariadb-git-e4f5e49cd6de1c9e4899a6e6f5c6666434e02437.tar.gz |
MDEV#4109: Galera: Valgrind warnings "blocks are still
reachable" in wsrep_init_startup on MTR tests
The initialization & de-initialization of wsrep plugin is solely
controlled by wsrep_on system variable. Now, as wsrep_on is ON by
default, the plugin gets initialized during server start. However,
there would be a leakage in case wsrep_on is turned off before plugin's
deinitialization (while server is shutting down) takes place, in which
case the deinit routine will not be invoked.
In this particular case, wsrep_on is turned off as no wsrep provider
has been specified & thus the valgrind warnings.
Fixed by introducing a flag which tracks and now controls the
(de|)initialization of the wsrep plugin instead on wsrep_on.
Added necessary asserts.
main.connect [ pass ] 16534
valgrind_report [ pass ]
-rw-r--r-- | sql/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 11 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 3 | ||||
-rw-r--r-- | sql/wsrep_var.cc | 3 |
4 files changed, 18 insertions, 2 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 80aa5c6a2f1..451269fcf56 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1751,7 +1751,8 @@ static void __cdecl kill_server(int sig_ptr) close_connections(); #ifdef WITH_WSREP - if (WSREP_ON) wsrep_deinit(); + if (wsrep_inited == 1) + wsrep_deinit(); #endif if (sig != MYSQL_KILL_SIGNAL && sig != 0) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 39c8349c4f2..2181054a34c 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -56,6 +56,11 @@ my_bool wsrep_desync = 0; // desynchronize the node from the c * End configuration options */ +/* + * Other wsrep global variables. + */ +my_bool wsrep_inited = 0; // initialized ? + static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; const wsrep_uuid_t* wsrep_cluster_uuid() { @@ -414,6 +419,7 @@ static void wsrep_init_position() int wsrep_init() { int rcode= -1; + DBUG_ASSERT(wsrep_inited == 0); wsrep_ready_set(FALSE); assert(wsrep_provider); @@ -442,6 +448,7 @@ int wsrep_init() { // enable normal operation in case no provider is specified wsrep_ready_set(TRUE); + wsrep_inited= 1; global_system_variables.wsrep_on = 0; return 0; } @@ -565,6 +572,8 @@ int wsrep_init() WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode); free(wsrep); wsrep = NULL; + } else { + wsrep_inited= 1; } return rcode; @@ -595,6 +604,7 @@ void wsrep_init_startup (bool first) void wsrep_deinit() { + DBUG_ASSERT(wsrep_inited == 1); wsrep_unload(wsrep); wsrep= 0; provider_name[0]= '\0'; @@ -603,6 +613,7 @@ void wsrep_deinit() delete wsrep_format_desc; wsrep_format_desc= NULL; + wsrep_inited= 0; } void wsrep_recover() diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 20d356a22a9..37e72123c59 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -117,6 +117,9 @@ extern const char* wsrep_provider_vendor; extern int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff); extern void wsrep_free_status(THD *thd); +// Other wsrep global variables +extern my_bool wsrep_inited; // whether wsrep is initialized ? + #define WSREP_SST_ADDRESS_AUTO "AUTO" #define WSREP_NODE_INCOMING_AUTO "AUTO" diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 94ac902506f..5dc9a475e0d 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -247,7 +247,8 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type) wsrep_stop_replication(thd); mysql_mutex_lock(&LOCK_global_system_variables); - wsrep_deinit(); + if (wsrep_inited == 1) + wsrep_deinit(); char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider //when fails |