Skip to content

Commit 845d7e1

Browse files
author
Luis Soares
committed
BUG#49259: Slave I/O thread could not register on master
The slave thread changed the format of the information it used to connect to the master after patch for BUG 13963. This resulted in old master getting confused, thence rejecting the slave connection attempt. In particular, patch for BUG 13963 removed the rpl_recovery_rank variable which was, at that time, packed together with the rest of the information which the slave would use to register itself on the master. Based on this data, the master would then assert that the number of bytes received in the connection command was consistent to what it was expecting. Therefore, given that a slave, patched with the aforementioned patch, would not pack the four bytes related to the rpl_recovery_rank variable, the old master would reject the connection attempt. It would assume that the data was inconsistent (fewer bytes than it was expecting) and return an error. We fix this by faking an rpl_recovery_rank variable when registering the slave on the master. In practice this reverts a small part of patch for BUG 13963, the one related to the slave connecting to the master.
1 parent 0758893 commit 845d7e1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

sql/repl_failsafe.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,18 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
183183
get_object(p,si->host, "Failed to register slave: too long 'report-host'");
184184
get_object(p,si->user, "Failed to register slave: too long 'report-user'");
185185
get_object(p,si->password, "Failed to register slave; too long 'report-password'");
186-
/*6 is the total length of port and master_id*/
187-
if (p+6 != p_end)
186+
if (p+10 > p_end)
188187
goto err;
189188
si->port= uint2korr(p);
190189
p += 2;
190+
/*
191+
We need to by pass the bytes used in the fake rpl_recovery_rank
192+
variable. It was removed in patch for BUG#13963. But this would
193+
make a server with that patch unable to connect to an old master.
194+
See: BUG#49259
195+
*/
196+
// si->rpl_recovery_rank= uint4korr(p);
197+
p += 4;
191198
if (!(si->master_id= uint4korr(p)))
192199
si->master_id= server_id;
193200
si->thd= thd;

sql/slave.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,12 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi,
16121612
pos= net_store_data(pos, (uchar*) report_user, report_user_len);
16131613
pos= net_store_data(pos, (uchar*) report_password, report_password_len);
16141614
int2store(pos, (uint16) report_port); pos+= 2;
1615+
/*
1616+
Fake rpl_recovery_rank, which was removed in BUG#13963,
1617+
so that this server can register itself on old servers,
1618+
see BUG#49259.
1619+
*/
1620+
int4store(pos, /* rpl_recovery_rank */ 0); pos+= 4;
16151621
/* The master will fill in master_id */
16161622
int4store(pos, 0); pos+= 4;
16171623

0 commit comments

Comments
 (0)