Skip to content

Commit dc377fc

Browse files
author
Nirbhay Choubey
committed
Merge of patch for MDEV-6411 from maria-5.5-galera.
1 parent 3d1ac12 commit dc377fc

File tree

8 files changed

+94
-27
lines changed

8 files changed

+94
-27
lines changed

mysql-test/suite/wsrep/r/variables.result

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SET SESSION wsrep_replicate_myisam= ON;
1111
ERROR HY000: Variable 'wsrep_replicate_myisam' is a GLOBAL variable and should be set with SET GLOBAL
1212
SET GLOBAL wsrep_replicate_myisam= ON;
1313
SET GLOBAL wsrep_replicate_myisam= OFF;
14+
SET GLOBAL wsrep_provider=none;
1415
#
1516
# MDEV#5790: SHOW GLOBAL STATUS LIKE does not show the correct list of
1617
# variables when using "_"
@@ -144,7 +145,7 @@ call mtr.add_suppression("safe_mutex: Found wrong usage of mutex 'LOCK_wsrep_sla
144145
call mtr.add_suppression("WSREP: Failed to get provider options");
145146
SELECT @@global.wsrep_provider;
146147
@@global.wsrep_provider
147-
none
148+
libgalera_smm.so
148149
SELECT @@global.wsrep_slave_threads;
149150
@@global.wsrep_slave_threads
150151
1
@@ -160,7 +161,7 @@ wsrep_thread_count 0
160161

161162
SELECT @@global.wsrep_provider;
162163
@@global.wsrep_provider
163-
/usr/lib/galera/libgalera_smm.so
164+
libgalera_smm.so
164165
SELECT @@global.wsrep_cluster_address;
165166
@@global.wsrep_cluster_address
166167
NULL
@@ -177,7 +178,7 @@ SET GLOBAL wsrep_cluster_address= 'gcomm://';
177178
# Wait for applier threads to get created.
178179
SELECT @@global.wsrep_provider;
179180
@@global.wsrep_provider
180-
/usr/lib/galera/libgalera_smm.so
181+
libgalera_smm.so
181182
SELECT @@global.wsrep_cluster_address;
182183
@@global.wsrep_cluster_address
183184
gcomm://
@@ -201,4 +202,21 @@ SET GLOBAL wsrep_slave_threads= @wsrep_slave_threads_saved;
201202
SET GLOBAL wsrep_provider= none;
202203
SET GLOBAL wsrep_cluster_address= '';
203204
SET GLOBAL wsrep_provider_options= '';
205+
#
206+
# MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash
207+
#
208+
SET @wsrep_sst_auth_saved= @@global.wsrep_sst_auth;
209+
SET @@global.wsrep_sst_auth= 'user:pass';
210+
SELECT @@global.wsrep_sst_auth;
211+
@@global.wsrep_sst_auth
212+
********
213+
SET @@global.wsrep_sst_auth= '';
214+
SELECT @@global.wsrep_sst_auth;
215+
@@global.wsrep_sst_auth
216+
217+
SET @@global.wsrep_sst_auth= NULL;
218+
SELECT @@global.wsrep_sst_auth;
219+
@@global.wsrep_sst_auth
220+
NULL
221+
SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
204222
# End of test.

mysql-test/suite/wsrep/t/variables.test

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SET GLOBAL wsrep_replicate_myisam= ON;
1919

2020
# Reset it back.
2121
SET GLOBAL wsrep_replicate_myisam= OFF;
22+
SET GLOBAL wsrep_provider=none;
2223

2324
--echo #
2425
--echo # MDEV#5790: SHOW GLOBAL STATUS LIKE does not show the correct list of
@@ -27,6 +28,10 @@ SET GLOBAL wsrep_replicate_myisam= OFF;
2728

2829
CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*");
2930

31+
--disable_query_log
32+
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
33+
--enable_query_log
34+
3035
--replace_column 2 #
3136
SHOW GLOBAL STATUS LIKE 'wsrep%';
3237

@@ -40,6 +45,7 @@ SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';
4045
--echo # Should show nothing.
4146
SHOW STATUS LIKE 'x';
4247

48+
# Reset it back.
4349
SET GLOBAL wsrep_provider=none;
4450

4551
--echo #
@@ -59,6 +65,7 @@ SHOW STATUS LIKE 'wsrep_local_state_uuid';
5965
--replace_column 2 #
6066
SHOW STATUS LIKE 'wsrep_last_committed';
6167

68+
# Reset it back.
6269
SET GLOBAL wsrep_provider=none;
6370

6471
--echo
@@ -67,6 +74,12 @@ SET GLOBAL wsrep_provider=none;
6774
--echo #
6875
call mtr.add_suppression("safe_mutex: Found wrong usage of mutex 'LOCK_wsrep_slave_threads' and 'LOCK_global_system_variables'");
6976
call mtr.add_suppression("WSREP: Failed to get provider options");
77+
78+
--disable_query_log
79+
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
80+
--enable_query_log
81+
82+
--replace_regex /.*libgalera_smm.*/libgalera_smm.so/
7083
SELECT @@global.wsrep_provider;
7184
SELECT @@global.wsrep_slave_threads;
7285
SELECT @@global.wsrep_cluster_address;
@@ -77,6 +90,8 @@ SHOW STATUS LIKE 'wsrep_thread_count';
7790
--disable_query_log
7891
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
7992
--enable_query_log
93+
94+
--replace_regex /.*libgalera_smm.*/libgalera_smm.so/
8095
SELECT @@global.wsrep_provider;
8196
SELECT @@global.wsrep_cluster_address;
8297
SHOW STATUS LIKE 'threads_connected';
@@ -88,6 +103,8 @@ SHOW STATUS LIKE 'wsrep_thread_count';
88103
SET GLOBAL wsrep_cluster_address= 'gcomm://';
89104
--echo # Wait for applier threads to get created.
90105
sleep 3;
106+
107+
--replace_regex /.*libgalera_smm.*/libgalera_smm.so/
91108
SELECT @@global.wsrep_provider;
92109
SELECT @@global.wsrep_cluster_address;
93110
SHOW STATUS LIKE 'threads_connected';
@@ -107,4 +124,17 @@ SET GLOBAL wsrep_provider= none;
107124
SET GLOBAL wsrep_cluster_address= '';
108125
SET GLOBAL wsrep_provider_options= '';
109126

127+
--echo #
128+
--echo # MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash
129+
--echo #
130+
SET @wsrep_sst_auth_saved= @@global.wsrep_sst_auth;
131+
SET @@global.wsrep_sst_auth= 'user:pass';
132+
SELECT @@global.wsrep_sst_auth;
133+
SET @@global.wsrep_sst_auth= '';
134+
SELECT @@global.wsrep_sst_auth;
135+
SET @@global.wsrep_sst_auth= NULL;
136+
SELECT @@global.wsrep_sst_auth;
137+
SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
138+
110139
--echo # End of test.
140+

sql/mysqld.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ static void __cdecl kill_server(int sig_ptr)
19591959
close_connections();
19601960
#ifdef WITH_WSREP
19611961
if (wsrep_inited == 1)
1962-
wsrep_deinit();
1962+
wsrep_deinit(true);
19631963
#endif
19641964
if (sig != MYSQL_KILL_SIGNAL &&
19651965
sig != 0)
@@ -2071,7 +2071,7 @@ extern "C" void unireg_abort(int exit_code)
20712071

20722072
/* In bootstrap mode we deinitialize wsrep here. */
20732073
if (opt_bootstrap && wsrep_inited)
2074-
wsrep_deinit();
2074+
wsrep_deinit(true);
20752075
}
20762076
#endif // WITH_WSREP
20772077
clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */

sql/wsrep_mysqld.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ void wsrep_init_startup (bool first)
720720
}
721721

722722

723-
void wsrep_deinit()
723+
void wsrep_deinit(bool free_options)
724724
{
725725
DBUG_ASSERT(wsrep_inited == 1);
726726
wsrep_unload(wsrep);
@@ -729,6 +729,11 @@ void wsrep_deinit()
729729
provider_version[0]= '\0';
730730
provider_vendor[0]= '\0';
731731
wsrep_inited= 0;
732+
733+
if (free_options)
734+
{
735+
wsrep_sst_auth_free();
736+
}
732737
}
733738

734739
void wsrep_recover()

sql/wsrep_mysqld.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void wsrep_free_status(THD *thd);
124124
void wsrep_filter_new_cluster (int* argc, char* argv[]);
125125

126126
int wsrep_init();
127-
void wsrep_deinit();
127+
void wsrep_deinit(bool free_options);
128128
void wsrep_recover();
129129
bool wsrep_before_SE(); // initialize wsrep before storage
130130
// engines (true) or after (false)

sql/wsrep_sst.cc

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,44 @@ bool wsrep_sst_auth_check (sys_var *self, THD* thd, set_var* var)
123123
{
124124
return 0;
125125
}
126+
126127
static bool sst_auth_real_set (const char* value)
127128
{
128-
const char* v = strdup (value);
129+
const char* v= NULL;
129130

130-
if (v)
131-
{
132-
if (sst_auth_real) free (const_cast<char*>(sst_auth_real));
133-
sst_auth_real = v;
131+
if (value)
132+
{
133+
v= my_strdup(value, MYF(0));
134+
}
135+
else // its NULL
136+
{
137+
wsrep_sst_auth_free();
138+
return 0;
139+
}
134140

135-
if (strlen(sst_auth_real))
136-
{
137-
if (wsrep_sst_auth)
138-
{
139-
my_free ((void*)wsrep_sst_auth);
140-
wsrep_sst_auth = my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
141-
//strncpy (wsrep_sst_auth, WSREP_SST_AUTH_MASK,
142-
// sizeof(wsrep_sst_auth) - 1);
143-
}
144-
else
145-
wsrep_sst_auth = my_strdup (WSREP_SST_AUTH_MASK, MYF(0));
146-
}
147-
return 0;
141+
if (v)
142+
{
143+
// set sst_auth_real
144+
if (sst_auth_real) { my_free((void *) sst_auth_real); }
145+
sst_auth_real = v;
146+
147+
// mask wsrep_sst_auth
148+
if (strlen(sst_auth_real))
149+
{
150+
if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); }
151+
wsrep_sst_auth= my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
148152
}
153+
return 0;
154+
}
155+
return 1;
156+
}
149157

150-
return 1;
158+
void wsrep_sst_auth_free()
159+
{
160+
if (wsrep_sst_auth) { my_free((void *) wsrep_sst_auth); }
161+
if (sst_auth_real) { my_free((void *) sst_auth_real); }
162+
wsrep_sst_auth= NULL;
163+
sst_auth_real= NULL;
151164
}
152165

153166
bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type)

sql/wsrep_sst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern void wsrep_sst_grab();
3131
extern bool wsrep_sst_wait();
3232
/*! Signals wsrep that initialization is complete, writesets can be applied */
3333
extern void wsrep_sst_continue();
34+
extern void wsrep_sst_auth_free();
3435

3536
extern void wsrep_SE_init_grab(); /*! grab init critical section */
3637
extern void wsrep_SE_init_wait(); /*! wait for SE init to complete */

sql/wsrep_var.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
239239
mysql_mutex_lock(&LOCK_global_system_variables);
240240

241241
if (wsrep_inited == 1)
242-
wsrep_deinit();
242+
wsrep_deinit(false);
243243

244244
char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider
245245
//when fails

0 commit comments

Comments
 (0)