MXS-1886 Better auto-rejoin error description and tolerance

Contains changes from commit 09df01752812444c6e7c409a8957d292f7de63cf
adapted to the 2.3 branch.
This commit is contained in:
Esa Korhonen
2018-06-15 17:29:00 +03:00
parent d3e9cc9a4f
commit 019d62bbb8
5 changed files with 47 additions and 16 deletions

View File

@ -537,12 +537,33 @@ bool MariaDBServer::update_slave_info()
update_gtids() && do_show_slave_status());
}
bool MariaDBServer::can_replicate_from(MariaDBServer* master)
bool MariaDBServer::can_replicate_from(MariaDBServer* master, string* error_out)
{
bool rval = false;
if (update_gtids())
{
rval = m_gtid_current_pos.can_replicate_from(master->m_gtid_binlog_pos);
if (m_gtid_current_pos.empty())
{
*error_out = string("'") + name() + "' does not have a valid 'gtid_current_pos'.";
}
else if (master->m_gtid_binlog_pos.empty())
{
*error_out = string("'") + master->name() + "' does not have a valid 'gtid_binlog_pos'.";
}
else
{
rval = m_gtid_current_pos.can_replicate_from(master->m_gtid_binlog_pos);
if (!rval)
{
*error_out = string("gtid_current_pos of '") + name() + "' (" +
m_gtid_current_pos.to_string() + ") is incompatible with gtid_binlog_pos of '" +
master->name() + "' (" + master->m_gtid_binlog_pos.to_string() + ").";
}
}
}
else
{
*error_out = string("Server '") + name() + "' could not be queried.";
}
return rval;
}