Commit 140fd7ad authored by Nirbhay Choubey's avatar Nirbhay Choubey

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.
parent 6421f5f1
......@@ -4,10 +4,10 @@
call mtr.add_suppression("WSREP: Failed to get provider options");
# save the initial value
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
# default
SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name
# default (expect 1)
SELECT COUNT(@@global.wsrep_node_name);
COUNT(@@global.wsrep_node_name)
1
# scope
SELECT @@session.wsrep_node_name;
......@@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name
hyphenated-node-name
SET @@global.wsrep_node_name=default;
SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name
# default (expect 1)
SELECT COUNT(@@global.wsrep_node_name);
COUNT(@@global.wsrep_node_name)
1
# invalid values
SET @@global.wsrep_node_name=NULL;
ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL'
SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name
SELECT COUNT(@@global.wsrep_node_name);
COUNT(@@global.wsrep_node_name)
1
SET @@global.wsrep_node_name=1;
ERROR 42000: Incorrect argument type to variable 'wsrep_node_name'
SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name
SELECT COUNT(@@global.wsrep_node_name);
COUNT(@@global.wsrep_node_name)
1
#
# MDEV-6699 : wsrep_node_name not automaticly set to hostname
#
SET @@global.wsrep_node_name=default;
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname';
@@GLOBAL.wsrep_node_name = VARIABLE_VALUE
1
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name';
@@GLOBAL.wsrep_node_name = VARIABLE_VALUE
1
# restore the initial value
SET @@global.wsrep_node_name = @wsrep_node_name_global_saved;
......
......@@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options");
--echo # save the initial value
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
--echo # default
SELECT @@global.wsrep_node_name;
--echo # default (expect 1)
SELECT COUNT(@@global.wsrep_node_name);
--echo
--echo # scope
......@@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name;
SET @@global.wsrep_node_name='hyphenated-node-name';
SELECT @@global.wsrep_node_name;
SET @@global.wsrep_node_name=default;
SELECT @@global.wsrep_node_name;
--echo # default (expect 1)
SELECT COUNT(@@global.wsrep_node_name);
--echo
--echo # invalid values
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_node_name=NULL;
SELECT @@global.wsrep_node_name;
SELECT COUNT(@@global.wsrep_node_name);
--error ER_WRONG_TYPE_FOR_VAR
SET @@global.wsrep_node_name=1;
SELECT @@global.wsrep_node_name;
SELECT COUNT(@@global.wsrep_node_name);
--echo #
--echo # MDEV-6699 : wsrep_node_name not automaticly set to hostname
--echo #
SET @@global.wsrep_node_name=default;
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname';
SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name';
--echo
--echo # restore the initial value
......
......@@ -3705,13 +3705,6 @@ static int init_common_variables()
}
else
opt_log_basename= glob_hostname;
#ifdef WITH_WSREP
if (0 == wsrep_node_name || 0 == wsrep_node_name[0])
{
my_free((void *)wsrep_node_name);
wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME));
}
#endif /* WITH_WSREP */
if (!*pidfile_name)
{
strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);
......
......@@ -3731,7 +3731,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address (
static Sys_var_charptr Sys_wsrep_node_name (
"wsrep_node_name", "Node name",
PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG),
IN_FS_CHARSET, DEFAULT(""), NO_MUTEX_GUARD, NOT_IN_BINLOG,
IN_FS_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG,
wsrep_node_name_check, wsrep_node_name_update);
static Sys_var_charptr Sys_wsrep_node_address (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment