diff options
author | <Li-Bing.Song@sun.com> | 2009-10-20 14:30:15 +0800 |
---|---|---|
committer | <Li-Bing.Song@sun.com> | 2009-10-20 14:30:15 +0800 |
commit | d17245e772eea94cc77f8eabbc94b39bd226dfac (patch) | |
tree | f45d87cf5e0635994d2b198001e60d8e04680b34 /sql/slave.cc | |
parent | c1584c98010515b3c51c1d0987b824182e0610aa (diff) | |
download | mariadb-git-d17245e772eea94cc77f8eabbc94b39bd226dfac.tar.gz |
Bug#13963 SHOW SLAVE HOSTS is unreliable
Before the patch, slaves only appear in the output of SHOW SLAVE HOSTS
when report-host option is set. If an expected slave does not appear in
the list, nobody knows whether the slave does not connect or has started
without the "report-host" option. The output also contains a strange
field "Rpl_recovery_rank" which has never been implemented and the manual
of MySQL5.4 declares that the field has been removed from MySQL5.4.
This patch is done with these,
According to the manual of MySQL5.4, "Rpl_recovery_rank" is removed.
Slaves will register themselves to master no matter if report_host option is set
or not. When slaves are registering themselves, their Server_ids, report_host
and other information are together sent to master. Sever_ids are never null
and is unique in one replication group. Slaves always can be identified with
different Server_ids no matter if report_host exists.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 834ed8ed933..36111ef2bc9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1745,28 +1745,48 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi, bool *suppress_warnings) { uchar buf[1024], *pos= buf; - uint report_host_len, report_user_len=0, report_password_len=0; + uint report_host_len=0, report_user_len=0, report_password_len=0; DBUG_ENTER("register_slave_on_master"); *suppress_warnings= FALSE; - if (!report_host) + if (report_host) + report_host_len= strlen(report_host); + if (report_host_len > HOSTNAME_LENGTH) + { + sql_print_warning("The length of report_host is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_host_len, HOSTNAME_LENGTH); DBUG_RETURN(0); - report_host_len= strlen(report_host); + } + if (report_user) report_user_len= strlen(report_user); + if (report_user_len > USERNAME_LENGTH) + { + sql_print_warning("The length of report_user is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_user_len, USERNAME_LENGTH); + DBUG_RETURN(0); + } + if (report_password) report_password_len= strlen(report_password); - /* 30 is a good safety margin */ - if (report_host_len + report_user_len + report_password_len + 30 > - sizeof(buf)) - DBUG_RETURN(0); // safety + if (report_password_len > MAX_PASSWORD_LENGTH) + { + sql_print_warning("The length of report_password is %d. " + "It is larger than the max length(%d), so this " + "slave cannot be registered to the master.", + report_password_len, MAX_PASSWORD_LENGTH); + DBUG_RETURN(0); + } int4store(pos, server_id); pos+= 4; pos= net_store_data(pos, (uchar*) report_host, report_host_len); pos= net_store_data(pos, (uchar*) report_user, report_user_len); pos= net_store_data(pos, (uchar*) report_password, report_password_len); int2store(pos, (uint16) report_port); pos+= 2; - int4store(pos, rpl_recovery_rank); pos+= 4; /* The master will fill in master_id */ int4store(pos, 0); pos+= 4; |