Bug #49259 Slave I/O thread could not register on master
Submitted: 1 Dec 2009 13:10 Modified: 8 Mar 2010 8:29
Reporter: Serge Kozlov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:mysql-next-mr OS:Any
Assigned to: Luis Soares CPU Architecture:Any
Tags: error 1105, slave, versional replication

[1 Dec 2009 13:10] Serge Kozlov
Description:
There are two following servers:
1. master is mysql-5.1-bugteam
2. slave is mysql-5.1-rep+2

CHANGE MASTER and START SLAVE return no errors but really slave isn't connected and its error.log has following:

091201 15:21:26 [Note] Slave I/O thread: connected to master 'root@127.0.0.1:10000',replication started in log 'FIRST' at position 4
091201 15:21:26 [ERROR] Slave I/O: Master command COM_REGISTER_SLAVE failed: Wrong parameters to function register_slave (Errno: 1105), Error_code: 1597
091201 15:21:26 [ERROR] Slave I/O thread couldn't register on master
091201 15:21:26 [Warning] Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again, log 'FIRST' at postion 4, Error_code: 1597
091201 15:21:26 [ERROR] Slave I/O: Master command COM_REGISTER_SLAVE failed: Wrong parameters to function register_slave (Errno: 1105), Error_code: 1597
091201 15:21:26 [ERROR] Slave I/O thread couldn't register on master
091201 15:21:26 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log './vtop-relay-bin.000001' position: 4
091201 15:22:26 [Warning] Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again, log 'FIRST' at postion 4, Error_code: 1597
091201 15:22:26 [ERROR] Slave I/O: Master command COM_REGISTER_SLAVE failed: Wrong parameters to function register_slave (Errno: 1105), Error_code: 1597
091201 15:22:26 [ERROR] Slave I/O thread couldn't register on master
091201 15:23:26 [Warning] Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again, log 'FIRST' at postion 4, Error_code: 1597
091201 15:23:26 [ERROR] Slave I/O: Master command COM_REGISTER_SLAVE failed: Wrong parameters to function register_slave (Errno: 1105), Error_code: 1597
091201 15:23:26 [ERROR] Slave I/O thread couldn't register on master
091201 15:24:26 [Warning] Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again, log 'FIRST' at postion 4, Error_code: 1597
091201 15:24:26 [ERROR] Slave I/O: Master command COM_REGISTER_SLAVE failed: Wrong parameters to function register_slave (Errno: 1105), Error_code: 1597
091201 15:24:26 [ERROR] Slave I/O thread couldn't register on master
091201 15:25:26 [Warning] Slave I/O: Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again, log 'FIRST' at postion 4, Error_code: 1597
....

How to repeat:
Use Nuts for testing:
1. Run from nuts home:
./bin/nuts.pl --build=/path/to/5.1-bugteam --build=/path/to/5.1-rep+3 --test=replication.
2. Look (from nuts home):
var/log/samples::replication/2.log
[1 Dec 2009 13:49] Serge Kozlov
Fix for item 1 from steps:
./bin/nuts.pl --build=/path/to/5.1-bugteam --build=/path/to/5.1-rep+3
--buildorder=0,1 --test=replication.
[9 Dec 2009 15:51] Serge Kozlov
It happens for pair mysql-5.1-bugteam (master) and mysql-next-mr (slave) so the internal tag TEAMTREE should be removed.
[18 Dec 2009 2:55] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/94877

3127 Luis Soares	2009-12-18
      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.
     @ sql/repl_failsafe.cc
        Added bypassing of removed rpl_recovery_rank variable information in
        packet. This should also make more sense when old servers connect
        to a new master (ie, master with patch for BUG 13963). If this was not
        done, the new master could interpert information an old slave sends as
        master_id, when in fact it could be the rpl_recovery_rank data.
     @ sql/slave.cc
        Faking a rpl_recovery_rank so that we can register as a slave in
        an old master.
[18 Jan 2010 12:06] Bugs System
Pushed into 6.0.14-alpha (revid:alik@ibmvm-20100118120357-hnzhgadkpzqfnvsc) (version source revid:alik@ibmvm-20100118115413-kd3klpine09yyktw) (merge vers: 6.0.14-alpha) (pib:16)
[18 Jan 2010 12:07] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100118120111-73dulkgc893it4r9) (version source revid:alik@ibmvm-20100118115335-0stecyzftqm7bqx6) (pib:16)
[19 Jan 2010 10:01] Jon Stephens
Documented bugfix in the 5.6.0 and 6.0.14 changelogs as follows:

        Due to a change in the format of the information used by the
        slave to connect to the master, which could cause to reject
        connection attempts to older masters by newer slaves.

Set NDI state, waiting for additional merges.
[6 Mar 2010 11:03] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@linux-rbsx-20100118220048-5vnyqi5ghsbgmdsd) (merge vers: 5.5.99-m3) (pib:16)
[8 Mar 2010 0:01] Paul DuBois
Moved 5.6.0 changelog entry to 5.5.3.