1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Always print slave host in SHOW SLAVE HOSTS

Since the client host can be extracted from the network connection, it can
always be printed. This makes it easier to find out where a slave is
replicating from. It could also be used to automatically discover slaves
that are replicating from a master.
This commit is contained in:
Markus Mäkelä
2019-07-04 12:59:18 +03:00
committed by Robert Bindar
parent 1e9aa46dc3
commit 0d5d8d2e7a
2 changed files with 5 additions and 2 deletions

View File

@@ -10,11 +10,11 @@ connection master;
SHOW SLAVE HOSTS; SHOW SLAVE HOSTS;
Server_id Host Port Master_id Server_id Host Port Master_id
3 slave2 SLAVE_PORT 1 3 slave2 SLAVE_PORT 1
2 SLAVE_PORT 1 2 localhost SLAVE_PORT 1
connection slave2; connection slave2;
include/stop_slave_io.inc include/stop_slave_io.inc
connection master; connection master;
SHOW SLAVE HOSTS; SHOW SLAVE HOSTS;
Server_id Host Port Master_id Server_id Host Port Master_id
2 SLAVE_PORT 1 2 localhost SLAVE_PORT 1
include/rpl_end.inc include/rpl_end.inc

View File

@@ -147,6 +147,9 @@ int THD::register_slave(uchar *packet, size_t packet_length)
if (!(si->master_id= uint4korr(p))) if (!(si->master_id= uint4korr(p)))
si->master_id= global_system_variables.server_id; si->master_id= global_system_variables.server_id;
if (!*si->host)
::strmake(si->host, main_security_ctx.host_or_ip, sizeof(si->host));
unregister_slave(); unregister_slave();
mysql_mutex_lock(&LOCK_thd_data); mysql_mutex_lock(&LOCK_thd_data);
slave_info= si; slave_info= si;