BUG#13333431 - INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT
Problem - The default port number shown in SHOW SLAVE HOSTS is always 3306 though the slave is actually listening on a different port number. This is a problem as the user can not be sure whether this port value can be trusted and so client trying to read replication topology can get confused. Fix - 3306 ceases to be the default value of report-port. Moreover report-port does not have a static default any longer. Instead we initialize report-port to 0 as the new default value and change it based on two checks : 1) If report_port is not set, the slave reports the port number its listening on. (i.e. if report-port is not set we get the actual value of the slave's port number). 2) If report-port is set, we show the value report-port is set to, as the slave's port number.
This commit is contained in:
commit
be866add06
3
mysql-test/include/show_slave_hosts.inc
Normal file
3
mysql-test/include/show_slave_hosts.inc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
|
||||||
|
--replace_regex /[0-9, a-f]{8}-[0-9, a-f]{4}-[0-9, a-f]{4}-[0-9, a-f]{4}-[0-9, a-f]{12}/SLAVE_UUID/
|
||||||
|
SHOW SLAVE HOSTS;
|
@ -915,7 +915,7 @@ relay-log-space-limit 0
|
|||||||
replicate-same-server-id FALSE
|
replicate-same-server-id FALSE
|
||||||
report-host (No default value)
|
report-host (No default value)
|
||||||
report-password (No default value)
|
report-password (No default value)
|
||||||
report-port 3306
|
report-port 0
|
||||||
report-user (No default value)
|
report-user (No default value)
|
||||||
rpl-recovery-rank 0
|
rpl-recovery-rank 0
|
||||||
safe-user-create FALSE
|
safe-user-create FALSE
|
||||||
|
15
mysql-test/suite/rpl/r/rpl_report_port.result
Normal file
15
mysql-test/suite/rpl/r/rpl_report_port.result
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
include/master-slave.inc
|
||||||
|
[connection master]
|
||||||
|
[The default value shown for the slave's port number is the actual port number of the slave]
|
||||||
|
SHOW SLAVE HOSTS;
|
||||||
|
Server_id Host Port Master_id
|
||||||
|
2 127.0.0.1 SLAVE_PORT 1
|
||||||
|
[The default value shown for the slave's port number is the actual port number of the slave]
|
||||||
|
include/rpl_restart_server.inc [server_number=2 parameters: --report-port=9000]
|
||||||
|
include/start_slave.inc
|
||||||
|
[Slave restarted with the report-port set to some value]
|
||||||
|
[The value shown for the slave's port number is 9000 which is the value set for report-port]
|
||||||
|
SHOW SLAVE HOSTS;
|
||||||
|
Server_id Host Port Master_id
|
||||||
|
2 127.0.0.1 9000 1
|
||||||
|
include/rpl_end.inc
|
@ -6,7 +6,7 @@ START SLAVE IO_THREAD;
|
|||||||
include/wait_for_slave_io_to_start.inc
|
include/wait_for_slave_io_to_start.inc
|
||||||
SHOW SLAVE HOSTS;
|
SHOW SLAVE HOSTS;
|
||||||
Server_id Host Port Master_id
|
Server_id Host Port Master_id
|
||||||
3 slave2 DEFAULT_PORT 1
|
3 slave2 SLAVE_PORT 1
|
||||||
2 SLAVE_PORT 1
|
2 SLAVE_PORT 1
|
||||||
include/stop_slave_io.inc
|
include/stop_slave_io.inc
|
||||||
SHOW SLAVE HOSTS;
|
SHOW SLAVE HOSTS;
|
||||||
|
1
mysql-test/suite/rpl/t/rpl_report_port-slave.opt
Normal file
1
mysql-test/suite/rpl/t/rpl_report_port-slave.opt
Normal file
@ -0,0 +1 @@
|
|||||||
|
--report-port=
|
59
mysql-test/suite/rpl/t/rpl_report_port.test
Normal file
59
mysql-test/suite/rpl/t/rpl_report_port.test
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#
|
||||||
|
#BUG#13333431 : INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT
|
||||||
|
#
|
||||||
|
# ==== Purpose ====
|
||||||
|
#
|
||||||
|
# The test show the default value printed for the slave's port number if the
|
||||||
|
# --report-port= <some value> is not set on the slave. This is different from
|
||||||
|
# the present scenario which show 3306 as the default value if the report-port
|
||||||
|
# is not set on the slave.
|
||||||
|
#
|
||||||
|
#====Method====
|
||||||
|
#
|
||||||
|
# Start replication with report port not set.This will give the actual port
|
||||||
|
# number of the slave (ie. SLAVE_PORT) for the on doing SHOW SLAVE HOSTS on
|
||||||
|
# the master.
|
||||||
|
# Restart the slave server with report port set to 9000 and start the slave.
|
||||||
|
# In this case on doing SHOW SLAVE HOSTS on the master, we get the port number
|
||||||
|
# of the slave to be 9000.
|
||||||
|
|
||||||
|
source include/master-slave.inc;
|
||||||
|
|
||||||
|
connection master;
|
||||||
|
|
||||||
|
--echo [The default value shown for the slave's port number is the actual port number of the slave]
|
||||||
|
source include/show_slave_hosts.inc;
|
||||||
|
|
||||||
|
# SLAVE_PORT is the value of the port we should get.
|
||||||
|
|
||||||
|
let $show_statement= SHOW SLAVE HOSTS;
|
||||||
|
let $field= Port;
|
||||||
|
let $condition= 'SLAVE_PORT';
|
||||||
|
source include/wait_show_condition.inc;
|
||||||
|
--echo [The default value shown for the slave's port number is the actual port number of the slave]
|
||||||
|
|
||||||
|
# Start the server with some value being passed to the report_port= <option>
|
||||||
|
# this will be used incase we have to mask the value of the slave's port
|
||||||
|
# number in certain situations.
|
||||||
|
|
||||||
|
--let $rpl_server_number= 2
|
||||||
|
--let $rpl_server_parameters= --report-port=9000
|
||||||
|
--source include/rpl_restart_server.inc
|
||||||
|
|
||||||
|
connection slave;
|
||||||
|
--source include/start_slave.inc
|
||||||
|
|
||||||
|
--echo [Slave restarted with the report-port set to some value]
|
||||||
|
connection master;
|
||||||
|
|
||||||
|
--echo [The value shown for the slave's port number is 9000 which is the value set for report-port]
|
||||||
|
--source include/show_slave_hosts.inc
|
||||||
|
|
||||||
|
# 9000 is the value of the port we should get.
|
||||||
|
|
||||||
|
let $show_statement= SHOW SLAVE HOSTS;
|
||||||
|
let $field= Port;
|
||||||
|
let $condition= '9000';
|
||||||
|
source include/wait_show_condition.inc;
|
||||||
|
|
||||||
|
--source include/rpl_end.inc
|
@ -25,6 +25,7 @@ let $field= Server_id;
|
|||||||
# 3 is server_id of slave2.
|
# 3 is server_id of slave2.
|
||||||
let $condition= ='3';
|
let $condition= ='3';
|
||||||
source include/wait_show_condition.inc;
|
source include/wait_show_condition.inc;
|
||||||
|
--replace_column 3 'SLAVE_PORT'
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
|
||||||
SHOW SLAVE HOSTS;
|
SHOW SLAVE HOSTS;
|
||||||
|
|
||||||
|
@ -2,18 +2,19 @@
|
|||||||
#
|
#
|
||||||
# only global
|
# only global
|
||||||
#
|
#
|
||||||
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
--replace_regex s/[0-9]+/DEFAULT_MASTER_PORT/
|
||||||
select @@global.report_port;
|
select @@global.report_port;
|
||||||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||||
select @@session.report_port;
|
select @@session.report_port;
|
||||||
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
--replace_column 2 'DEFAULT_MASTER_PORT'
|
||||||
show global variables like 'report_port';
|
show global variables like 'report_port';
|
||||||
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
--replace_column 2 'DEFAULT_MASTER_PORT'
|
||||||
show session variables like 'report_port';
|
show session variables like 'report_port';
|
||||||
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
--replace_column 2 'DEFAULT_MASTER_PORT'
|
||||||
select * from information_schema.global_variables where variable_name='report_port';
|
select * from information_schema.global_variables where variable_name='report_port';
|
||||||
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
--replace_column 2 'DEFAULT_MASTER_PORT'
|
||||||
select * from information_schema.session_variables where variable_name='report_port';
|
select * from information_schema.session_variables where variable_name='report_port';
|
||||||
|
--replace_column 2 'DEFAULT_MASTER_PORT'
|
||||||
|
|
||||||
#
|
#
|
||||||
# show that it's read-only
|
# show that it's read-only
|
||||||
|
@ -656,7 +656,7 @@ int mysqld_server_started= 0;
|
|||||||
File_parser_dummy_hook file_parser_dummy_hook;
|
File_parser_dummy_hook file_parser_dummy_hook;
|
||||||
|
|
||||||
/* replication parameters, if master_host is not NULL, we are a slave */
|
/* replication parameters, if master_host is not NULL, we are a slave */
|
||||||
uint report_port= MYSQL_PORT;
|
uint report_port= 0;
|
||||||
ulong master_retry_count=0;
|
ulong master_retry_count=0;
|
||||||
char *master_info_file;
|
char *master_info_file;
|
||||||
char *relay_log_info_file, *report_user, *report_password, *report_host;
|
char *relay_log_info_file, *report_user, *report_password, *report_host;
|
||||||
@ -1784,6 +1784,11 @@ static void network_init(void)
|
|||||||
|
|
||||||
set_ports();
|
set_ports();
|
||||||
|
|
||||||
|
if (report_port == 0)
|
||||||
|
{
|
||||||
|
report_port= mysqld_port;
|
||||||
|
}
|
||||||
|
DBUG_ASSERT(report_port != 0);
|
||||||
if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
|
if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
|
||||||
{
|
{
|
||||||
struct addrinfo *ai, *a;
|
struct addrinfo *ai, *a;
|
||||||
|
@ -2768,7 +2768,7 @@ static Sys_var_uint Sys_repl_report_port(
|
|||||||
"port or if you have a special tunnel from the master or other clients "
|
"port or if you have a special tunnel from the master or other clients "
|
||||||
"to the slave. If not sure, leave this option unset",
|
"to the slave. If not sure, leave this option unset",
|
||||||
READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG),
|
READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG),
|
||||||
VALID_RANGE(0, UINT_MAX), DEFAULT(MYSQL_PORT), BLOCK_SIZE(1));
|
VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Sys_var_mybool Sys_keep_files_on_create(
|
static Sys_var_mybool Sys_keep_files_on_create(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user