Bug #83327 call func simple_command COM_REGISTER_SLAVE failed
Submitted: 11 Oct 2016 2:14 Modified: 17 Oct 2016 2:27
Reporter: bee robert Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities: Binlog Events Severity:S2 (Serious)
Version:mysql-binary-log-events-1.0.2 OS:SUSE
Assigned to: CPU Architecture:Any

[11 Oct 2016 2:14] bee robert
Description:
here is the way:

std::string uri = "mysql://root:root@10.64.126.175:3306";
binary_log::system::Binary_log_driver *binLogDriver = binary_log::system::create_transport(uri.c_str());
if (NULL == binLogDriver)
{
    return -1;
}
binary_log::Binary_log binLog(binLogDriver);
binary_log::Decoder decode;
int ret = binLog.connect();
if (binary_log::ERR_OK != ret)
{
    std::cout << "can't connect to the master mysql server. errorCode :" << ret << " error msg: " << binary_log::str_error(ret) << std::endl;
        
    if (NULL != binLogDriver)
    {
        delete binLogDriver;
        binLogDriver = NULL;
    }

    return -1;
}

while the binLog.connect() is called, the error generated:
can't connect to the master mysql server. errorCode :2 error msg: Unexpected failure

so I changed the source code add some logs at mysql-binary-log-events-1.0.2-labs/bindings/src/tcp_driver.cpp that I found:

at line 190:  if (simple_command(conn, COM_REGISTER_SLAVE, buf, (size_t) (pos - buf), 0))  failed, and return the error:
error number:2014 error msg is: Commands out of sync; you can't run this command now

also I refer to the following link:
http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html

made changes after line 159: if(mysql_query(conn, "SET @master_binlog_checksum='NONE'"))

whatever I did the changes to add/remove/... after it, the same eorror generated at the line 190:  if (simple_command(conn, COM_REGISTER_SLAVE, buf, (size_t) (pos - buf), 0))
error number:2014 error msg is: Commands out of sync; you can't run this command now

How to repeat:
refer to the description

Suggested fix:
NA
[11 Oct 2016 4:07] bee robert
for mysql 5.6.* and 5.7.*
[11 Oct 2016 6:30] bee robert
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 3
[14 Oct 2016 11:58] MySQL Verification Team
Hello bee robert,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[14 Oct 2016 11:59] MySQL Verification Team
--

[umshastr@hod03]/export/umesh/server/source/bugs/binlog_events: cat bug83327.cpp
#include "binlog.h"

int main()
{
std::string uri = "mysql://root:root@127.0.0.1:3306";
binary_log::system::Binary_log_driver *binLogDriver = binary_log::system::create_transport(uri.c_str());
if (NULL == binLogDriver)
{
    return -1;
}
binary_log::Binary_log binLog(binLogDriver);
binary_log::Decoder decode;
int ret = binLog.connect();
if (binary_log::ERR_OK != ret)
{
    std::cout << "can't connect to the master mysql server. errorCode :" << ret << " error msg: " << binary_log::str_error(ret) << std::endl;

    if (NULL != binLogDriver)
    {
        delete binLogDriver;
        binLogDriver = NULL;
    }

    return -1;
}
return 0;
}
[umshastr@hod03]/export/umesh/server/source/bugs/binlog_events: g++ -g bug83327.cpp  -I /export/umesh/server/source/bugs/binlog_events/mysql-binary-log-events-1.0.2-labs/include/mysql-binary-log-events/ -I /export/umesh/server/source/bugs/binlog_events/mysql-5.7.15/include/ -L /export/umesh/server/source/bugs/binlog_events/mysql-binary-log-events-1.0.2-labs/lib/ /export/umesh/server/source/bugs/binlog_events/mysql-binary-log-events-1.0.2-labs/lib/libmysqlstream.a /export/umesh/server/source/bugs/binlog_events/mysql-binary-log-events-1.0.2-labs/lib/libbinlogevents.a -L /home/neha/mysql-server/mysql-5.7.6-m16/bld/lib/ /export/umesh/server/source/bugs/binlog_events/mysql-5.7.15/lib/libmysqlclient.a  -Wl,-Bdynamic -lpthread -lm -lrt -ldl -lrt -ldl -lz -o bug83327
[umshastr@hod03]/export/umesh/server/source/bugs/binlog_events:
[umshastr@hod03]/export/umesh/server/source/bugs/binlog_events: ./bug83327
can't connect to the master mysql server. errorCode :2 error msg: Unexpected failure
[17 Oct 2016 2:27] bee robert
how about the solution?