1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

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:
Manish Kumar
2012-02-28 14:02:27 +05:30
10 changed files with 94 additions and 9 deletions

View 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

View File

@@ -6,7 +6,7 @@ START SLAVE IO_THREAD;
include/wait_for_slave_io_to_start.inc
SHOW SLAVE HOSTS;
Server_id Host Port Master_id
3 slave2 DEFAULT_PORT 1
3 slave2 SLAVE_PORT 1
2 SLAVE_PORT 1
include/stop_slave_io.inc
SHOW SLAVE HOSTS;

View File

@@ -0,0 +1 @@
--report-port=

View 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

View File

@@ -25,6 +25,7 @@ let $field= Server_id;
# 3 is server_id of slave2.
let $condition= ='3';
source include/wait_show_condition.inc;
--replace_column 3 'SLAVE_PORT'
--replace_result $SLAVE_MYPORT SLAVE_PORT $DEFAULT_MASTER_PORT DEFAULT_PORT
SHOW SLAVE HOSTS;

View File

@@ -2,18 +2,19 @@
#
# only global
#
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
--replace_regex s/[0-9]+/DEFAULT_MASTER_PORT/
select @@global.report_port;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.report_port;
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
--replace_column 2 'DEFAULT_MASTER_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';
--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';
--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';
--replace_column 2 'DEFAULT_MASTER_PORT'
#
# show that it's read-only