Skip to content

Commit f3e95ca

Browse files
author
Nirbhay Choubey
committed
MDEV-6699 : wsrep_node_name not automatically set to hostname
Fixed by using hostname (glob_hostname) as default value for wsrep_node_name system variable. Added a test case.
1 parent 47fcca0 commit f3e95ca

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
call mtr.add_suppression("WSREP: Failed to get provider options");
55
# save the initial value
66
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
7-
# default
8-
SELECT @@global.wsrep_node_name;
9-
@@global.wsrep_node_name
10-
7+
# default (expect 1)
8+
SELECT COUNT(@@global.wsrep_node_name);
9+
COUNT(@@global.wsrep_node_name)
10+
1
1111

1212
# scope
1313
SELECT @@session.wsrep_node_name;
@@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name;
2727
@@global.wsrep_node_name
2828
hyphenated-node-name
2929
SET @@global.wsrep_node_name=default;
30-
SELECT @@global.wsrep_node_name;
31-
@@global.wsrep_node_name
32-
30+
# default (expect 1)
31+
SELECT COUNT(@@global.wsrep_node_name);
32+
COUNT(@@global.wsrep_node_name)
33+
1
3334

3435
# invalid values
3536
SET @@global.wsrep_node_name=NULL;
3637
ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL'
37-
SELECT @@global.wsrep_node_name;
38-
@@global.wsrep_node_name
39-
38+
SELECT COUNT(@@global.wsrep_node_name);
39+
COUNT(@@global.wsrep_node_name)
40+
1
4041
SET @@global.wsrep_node_name=1;
4142
ERROR 42000: Incorrect argument type to variable 'wsrep_node_name'
42-
SELECT @@global.wsrep_node_name;
43-
@@global.wsrep_node_name
44-
43+
SELECT COUNT(@@global.wsrep_node_name);
44+
COUNT(@@global.wsrep_node_name)
45+
1
46+
#
47+
# MDEV-6699 : wsrep_node_name not automaticly set to hostname
48+
#
49+
SET @@global.wsrep_node_name=default;
50+
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
51+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname';
52+
@@GLOBAL.wsrep_node_name = VARIABLE_VALUE
53+
1
54+
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
55+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name';
56+
@@GLOBAL.wsrep_node_name = VARIABLE_VALUE
57+
1
4558

4659
# restore the initial value
4760
SET @@global.wsrep_node_name = @wsrep_node_name_global_saved;

mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options");
99
--echo # save the initial value
1010
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
1111

12-
--echo # default
13-
SELECT @@global.wsrep_node_name;
12+
--echo # default (expect 1)
13+
SELECT COUNT(@@global.wsrep_node_name);
1414

1515
--echo
1616
--echo # scope
@@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name;
2626
SET @@global.wsrep_node_name='hyphenated-node-name';
2727
SELECT @@global.wsrep_node_name;
2828
SET @@global.wsrep_node_name=default;
29-
SELECT @@global.wsrep_node_name;
29+
--echo # default (expect 1)
30+
SELECT COUNT(@@global.wsrep_node_name);
3031

3132
--echo
3233
--echo # invalid values
3334
--error ER_WRONG_VALUE_FOR_VAR
3435
SET @@global.wsrep_node_name=NULL;
35-
SELECT @@global.wsrep_node_name;
36+
SELECT COUNT(@@global.wsrep_node_name);
3637
--error ER_WRONG_TYPE_FOR_VAR
3738
SET @@global.wsrep_node_name=1;
38-
SELECT @@global.wsrep_node_name;
39+
SELECT COUNT(@@global.wsrep_node_name);
40+
41+
--echo #
42+
--echo # MDEV-6699 : wsrep_node_name not automaticly set to hostname
43+
--echo #
44+
SET @@global.wsrep_node_name=default;
45+
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
46+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname';
47+
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
48+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name';
3949

4050
--echo
4151
--echo # restore the initial value

sql/mysqld.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4166,13 +4166,6 @@ static int init_common_variables()
41664166
}
41674167
else
41684168
opt_log_basename= glob_hostname;
4169-
#ifdef WITH_WSREP
4170-
if (0 == wsrep_node_name || 0 == wsrep_node_name[0])
4171-
{
4172-
my_free((void *)wsrep_node_name);
4173-
wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME));
4174-
}
4175-
#endif /* WITH_WSREP */
41764169
if (!*pidfile_name)
41774170
{
41784171
strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);

sql/sys_vars.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4530,7 +4530,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address (
45304530
static Sys_var_charptr Sys_wsrep_node_name (
45314531
"wsrep_node_name", "Node name",
45324532
PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG),
4533-
IN_FS_CHARSET, DEFAULT(""), NO_MUTEX_GUARD, NOT_IN_BINLOG,
4533+
IN_FS_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG,
45344534
wsrep_node_name_check, wsrep_node_name_update);
45354535

45364536
static Sys_var_charptr Sys_wsrep_node_address (

0 commit comments

Comments
 (0)