[Commits] Rev 3508: MDEV#6411 - Setting set @@global_wsrep_sst_auth=NULL in lp:~maria-captains/maria/maria-5.5-galera

Nirbhay Choubey nirbhay at skysql.com
Wed Jul 9 01:32:58 EEST 2014


At lp:~maria-captains/maria/maria-5.5-galera

------------------------------------------------------------
revno: 3508
revision-id: nirbhay at skysql.com-20140708223251-qssg2jho9n8lz1y8
parent: nirbhay at skysql.com-20140630130446-cp4x6gzr6w9697yc
committer: Nirbhay Choubey <nirbhay at skysql.com>
branch nick: maria-5.5-galera_6411
timestamp: Tue 2014-07-08 18:32:51 -0400
message:
  MDEV#6411 - Setting set @@global_wsrep_sst_auth=NULL
  causes crash
  
  Fixed by properly handling the NULL values.
-------------- next part --------------
=== modified file 'mysql-test/suite/wsrep/r/variables.result'
--- a/mysql-test/suite/wsrep/r/variables.result	2014-06-10 22:31:07 +0000
+++ b/mysql-test/suite/wsrep/r/variables.result	2014-07-08 22:32:51 +0000
@@ -76,4 +76,21 @@
 SET GLOBAL wsrep_provider= none;
 SET GLOBAL wsrep_cluster_address= '';
 SET GLOBAL wsrep_provider_options= '';
+#
+# MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash
+#
+SET @wsrep_sst_auth_saved= @@global.wsrep_sst_auth;
+SET @@global.wsrep_sst_auth= 'user:pass';
+SELECT @@global.wsrep_sst_auth;
+@@global.wsrep_sst_auth
+********
+SET @@global.wsrep_sst_auth= '';
+SELECT @@global.wsrep_sst_auth;
+@@global.wsrep_sst_auth
+
+SET @@global.wsrep_sst_auth= NULL;
+SELECT @@global.wsrep_sst_auth;
+@@global.wsrep_sst_auth
+NULL
+SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
 # End of test.

=== modified file 'mysql-test/suite/wsrep/t/variables.test'
--- a/mysql-test/suite/wsrep/t/variables.test	2014-06-10 22:31:07 +0000
+++ b/mysql-test/suite/wsrep/t/variables.test	2014-07-08 22:32:51 +0000
@@ -71,5 +71,17 @@
 SET GLOBAL wsrep_cluster_address= '';
 SET GLOBAL wsrep_provider_options= '';
 
+--echo #
+--echo # MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash
+--echo #
+SET @wsrep_sst_auth_saved= @@global.wsrep_sst_auth;
+SET @@global.wsrep_sst_auth= 'user:pass';
+SELECT @@global.wsrep_sst_auth;
+SET @@global.wsrep_sst_auth= '';
+SELECT @@global.wsrep_sst_auth;
+SET @@global.wsrep_sst_auth= NULL;
+SELECT @@global.wsrep_sst_auth;
+SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
+
 --echo # End of test.
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2014-06-11 21:13:03 +0000
+++ b/sql/mysqld.cc	2014-07-08 22:32:51 +0000
@@ -1759,7 +1759,7 @@
   close_connections();
 #ifdef WITH_WSREP
   if (wsrep_inited == 1)
-    wsrep_deinit();
+    wsrep_deinit(true);
 #endif
   if (sig != MYSQL_KILL_SIGNAL &&
       sig != 0)
@@ -1871,7 +1871,7 @@
 
     /* In bootstrap mode we deinitialize wsrep here. */
     if (opt_bootstrap && wsrep_inited)
-      wsrep_deinit();
+      wsrep_deinit(true);
   }
 #endif // WITH_WSREP
 

=== modified file 'sql/wsrep_mysqld.cc'
--- a/sql/wsrep_mysqld.cc	2014-06-10 21:00:32 +0000
+++ b/sql/wsrep_mysqld.cc	2014-07-08 22:32:51 +0000
@@ -696,7 +696,7 @@
 }
 
 
-void wsrep_deinit()
+void wsrep_deinit(bool free_options)
 {
   DBUG_ASSERT(wsrep_inited == 1);
   wsrep_unload(wsrep);
@@ -708,6 +708,11 @@
   delete wsrep_format_desc;
   wsrep_format_desc= NULL;
   wsrep_inited= 0;
+
+  if (free_options)
+  {
+    wsrep_sst_auth_free();
+  }
 }
 
 void wsrep_recover()

=== modified file 'sql/wsrep_mysqld.h'
--- a/sql/wsrep_mysqld.h	2014-06-10 21:00:32 +0000
+++ b/sql/wsrep_mysqld.h	2014-07-08 22:32:51 +0000
@@ -124,7 +124,7 @@
 void wsrep_filter_new_cluster (int* argc, char* argv[]);
 
 int  wsrep_init();
-void wsrep_deinit();
+void wsrep_deinit(bool free_options);
 void wsrep_recover();
 bool wsrep_before_SE(); // initialize wsrep before storage
                         // engines (true) or after (false)

=== modified file 'sql/wsrep_sst.cc'
--- a/sql/wsrep_sst.cc	2014-06-10 20:33:57 +0000
+++ b/sql/wsrep_sst.cc	2014-07-08 22:32:51 +0000
@@ -120,31 +120,44 @@
 {
     return 0;
 }
+
 static bool sst_auth_real_set (const char* value)
 {
-    const char* v = strdup (value);
-
-    if (v)
+  const char* v= NULL;
+
+  if (value)
+  {
+    v= my_strdup(value, MYF(0));
+  }
+  else                                          // its NULL
+  {
+    wsrep_sst_auth_free();
+    return 0;
+  }
+
+  if (v)
+  {
+    // set sst_auth_real
+    if (sst_auth_real) { my_free((void *) sst_auth_real); }
+    sst_auth_real = v;
+
+    // mask wsrep_sst_auth
+    if (strlen(sst_auth_real))
     {
-        if (sst_auth_real) free (const_cast<char*>(sst_auth_real));
-        sst_auth_real = v;
-
-        if (strlen(sst_auth_real))
-        {
-          if (wsrep_sst_auth)
-          {
-            my_free ((void*)wsrep_sst_auth);
-            wsrep_sst_auth = my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
-            //strncpy (wsrep_sst_auth, WSREP_SST_AUTH_MASK,
-            //     sizeof(wsrep_sst_auth) - 1);
-          }
-          else
-            wsrep_sst_auth = my_strdup (WSREP_SST_AUTH_MASK, MYF(0));
-        }
-        return 0;
+      if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); }
+      wsrep_sst_auth= my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
     }
+    return 0;
+  }
+  return 1;
+}
 
-    return 1;
+void wsrep_sst_auth_free()
+{
+  if (wsrep_sst_auth) { my_free((void *) wsrep_sst_auth); }
+  if (sst_auth_real) { my_free((void *) sst_auth_real); }
+  wsrep_sst_auth= NULL;
+  sst_auth_real= NULL;
 }
 
 bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type)

=== modified file 'sql/wsrep_sst.h'
--- a/sql/wsrep_sst.h	2014-01-09 19:54:57 +0000
+++ b/sql/wsrep_sst.h	2014-07-08 22:32:51 +0000
@@ -31,6 +31,7 @@
 extern bool wsrep_sst_wait();
 /*! Signals wsrep that initialization is complete, writesets can be applied */
 extern void wsrep_sst_continue();
+extern void wsrep_sst_auth_free();
 
 extern void wsrep_SE_init_grab();   /*! grab init critical section */
 extern void wsrep_SE_init_wait();   /*! wait for SE init to complete */

=== modified file 'sql/wsrep_var.cc'
--- a/sql/wsrep_var.cc	2014-06-15 17:53:43 +0000
+++ b/sql/wsrep_var.cc	2014-07-08 22:32:51 +0000
@@ -239,7 +239,7 @@
   mysql_mutex_lock(&LOCK_global_system_variables);
 
   if (wsrep_inited == 1)
-    wsrep_deinit();
+    wsrep_deinit(false);
 
   char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider 
                                      //when fails



More information about the commits mailing list