Commit b57232d3 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 e337fd13
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
call mtr.add_suppression("WSREP: Failed to get provider options"); call mtr.add_suppression("WSREP: Failed to get provider options");
# save the initial value # save the initial value
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
# default # default (expect 1)
SELECT @@global.wsrep_node_name; SELECT COUNT(@@global.wsrep_node_name);
@@global.wsrep_node_name COUNT(@@global.wsrep_node_name)
1
# scope # scope
SELECT @@session.wsrep_node_name; SELECT @@session.wsrep_node_name;
...@@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name; ...@@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name;
@@global.wsrep_node_name @@global.wsrep_node_name
hyphenated-node-name hyphenated-node-name
SET @@global.wsrep_node_name=default; SET @@global.wsrep_node_name=default;
SELECT @@global.wsrep_node_name; # default (expect 1)
@@global.wsrep_node_name SELECT COUNT(@@global.wsrep_node_name);
COUNT(@@global.wsrep_node_name)
1
# invalid values # invalid values
SET @@global.wsrep_node_name=NULL; SET @@global.wsrep_node_name=NULL;
ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL' ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL'
SELECT @@global.wsrep_node_name; SELECT COUNT(@@global.wsrep_node_name);
@@global.wsrep_node_name COUNT(@@global.wsrep_node_name)
1
SET @@global.wsrep_node_name=1; SET @@global.wsrep_node_name=1;
ERROR 42000: Incorrect argument type to variable 'wsrep_node_name' ERROR 42000: Incorrect argument type to variable 'wsrep_node_name'
SELECT @@global.wsrep_node_name; SELECT COUNT(@@global.wsrep_node_name);
@@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 # restore the initial value
SET @@global.wsrep_node_name = @wsrep_node_name_global_saved; SET @@global.wsrep_node_name = @wsrep_node_name_global_saved;
......
...@@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options"); ...@@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options");
--echo # save the initial value --echo # save the initial value
SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; SET @wsrep_node_name_global_saved = @@global.wsrep_node_name;
--echo # default --echo # default (expect 1)
SELECT @@global.wsrep_node_name; SELECT COUNT(@@global.wsrep_node_name);
--echo --echo
--echo # scope --echo # scope
...@@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name; ...@@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name;
SET @@global.wsrep_node_name='hyphenated-node-name'; SET @@global.wsrep_node_name='hyphenated-node-name';
SELECT @@global.wsrep_node_name; SELECT @@global.wsrep_node_name;
SET @@global.wsrep_node_name=default; SET @@global.wsrep_node_name=default;
SELECT @@global.wsrep_node_name; --echo # default (expect 1)
SELECT COUNT(@@global.wsrep_node_name);
--echo --echo
--echo # invalid values --echo # invalid values
--error ER_WRONG_VALUE_FOR_VAR --error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_node_name=NULL; SET @@global.wsrep_node_name=NULL;
SELECT @@global.wsrep_node_name; SELECT COUNT(@@global.wsrep_node_name);
--error ER_WRONG_TYPE_FOR_VAR --error ER_WRONG_TYPE_FOR_VAR
SET @@global.wsrep_node_name=1; 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
--echo # restore the initial value --echo # restore the initial value
......
...@@ -4190,14 +4190,6 @@ static int init_common_variables() ...@@ -4190,14 +4190,6 @@ static int init_common_variables()
else else
opt_log_basename= glob_hostname; opt_log_basename= glob_hostname;
#ifdef WITH_WSREP
if (wsrep_node_name == 0 || wsrep_node_name[0] == 0)
{
my_free((void *)wsrep_node_name);
wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME));
}
#endif /* WITH_WSREP */
strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5); strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name);
......
...@@ -4730,7 +4730,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address ( ...@@ -4730,7 +4730,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address (
static Sys_var_charptr Sys_wsrep_node_name ( static Sys_var_charptr Sys_wsrep_node_name (
"wsrep_node_name", "Node name", "wsrep_node_name", "Node name",
PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG), PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG),
IN_SYSTEM_CHARSET, DEFAULT(""), NO_MUTEX_GUARD, NOT_IN_BINLOG, IN_SYSTEM_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG,
wsrep_node_name_check, wsrep_node_name_update); wsrep_node_name_check, wsrep_node_name_update);
static Sys_var_charptr Sys_wsrep_node_address ( 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