MXS-2158 Clean up gtid updating during rejoin
Error messages from update_gtids() are now printed. can_replicate_from() no longer updates gtid:s.
This commit is contained in:
parent
715eaf6760
commit
6a1cfddb43
@ -118,7 +118,8 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output)
|
||||
|
||||
if (server_is_rejoin_suspect(slave_cand, output))
|
||||
{
|
||||
if (m_master->update_gtids())
|
||||
string gtid_update_error;
|
||||
if (m_master->update_gtids(>id_update_error))
|
||||
{
|
||||
string no_rejoin_reason;
|
||||
if (slave_cand->can_replicate_from(m_master, &no_rejoin_reason))
|
||||
@ -138,18 +139,15 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output)
|
||||
else
|
||||
{
|
||||
PRINT_MXS_JSON_ERROR(output,
|
||||
"Server '%s' cannot replicate from cluster master '%s': "
|
||||
"%s.",
|
||||
rejoin_serv_name,
|
||||
m_master->name(),
|
||||
no_rejoin_reason.c_str());
|
||||
"%s cannot replicate from cluster master %s: %s.",
|
||||
rejoin_serv_name, m_master->name(), no_rejoin_reason.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT_MXS_JSON_ERROR(output,
|
||||
"Cluster master '%s' gtid info could not be updated.",
|
||||
m_master->name());
|
||||
"The GTIDs of master server %s could not be updated: %s",
|
||||
m_master->name(), gtid_update_error.c_str());
|
||||
}
|
||||
} // server_is_rejoin_suspect has added any error messages to the output, no need to print here
|
||||
}
|
||||
@ -687,7 +685,8 @@ bool MariaDBMonitor::get_joinable_servers(ServerArray* output)
|
||||
bool comm_ok = true;
|
||||
if (!suspects.empty())
|
||||
{
|
||||
if (m_master->update_gtids())
|
||||
string gtid_update_error;
|
||||
if (m_master->update_gtids(>id_update_error))
|
||||
{
|
||||
for (size_t i = 0; i < suspects.size(); i++)
|
||||
{
|
||||
@ -710,6 +709,8 @@ bool MariaDBMonitor::get_joinable_servers(ServerArray* output)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("The GTIDs of master server %s could not be updated while attempting an automatic "
|
||||
"rejoin: %s", m_master->name(), gtid_update_error.c_str());
|
||||
comm_ok = false;
|
||||
}
|
||||
}
|
||||
@ -1760,10 +1761,7 @@ void MariaDBMonitor::handle_auto_rejoin()
|
||||
MXS_NOTICE("%d server(s) redirected or rejoined the cluster.", joins);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Query error to master '%s' prevented a possible rejoin operation.", m_master->name());
|
||||
}
|
||||
// get_joinable_servers prints an error if master is unresponsive
|
||||
}
|
||||
|
||||
void MariaDBMonitor::report_and_disable(const string& operation, const string& setting_name,
|
||||
|
@ -693,35 +693,32 @@ json_t* MariaDBServer::to_json() const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MariaDBServer::can_replicate_from(MariaDBServer* master, string* error_out)
|
||||
bool MariaDBServer::can_replicate_from(MariaDBServer* master, string* reason_out)
|
||||
{
|
||||
bool rval = false;
|
||||
if (update_gtids())
|
||||
mxb_assert(reason_out);
|
||||
mxb_assert(is_usable()); // The server must be running.
|
||||
|
||||
bool can_replicate = false;
|
||||
if (m_gtid_current_pos.empty())
|
||||
{
|
||||
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() + ").";
|
||||
}
|
||||
}
|
||||
*reason_out = string_printf("%s does not have a valid gtid_current_pos.", name());
|
||||
}
|
||||
else if (master->m_gtid_binlog_pos.empty())
|
||||
{
|
||||
*reason_out = string_printf("%s does not have a valid gtid_binlog_pos.", master->name());
|
||||
}
|
||||
else
|
||||
{
|
||||
*error_out = string("Server '") + name() + "' could not be queried.";
|
||||
can_replicate = m_gtid_current_pos.can_replicate_from(master->m_gtid_binlog_pos);
|
||||
if (!can_replicate)
|
||||
{
|
||||
*reason_out = string_printf("gtid_current_pos of %s (%s) is incompatible with "
|
||||
"gtid_binlog_pos of %s (%s).",
|
||||
name(), m_gtid_current_pos.to_string().c_str(),
|
||||
master->name(), master->m_gtid_binlog_pos.to_string().c_str());
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
return can_replicate;
|
||||
}
|
||||
|
||||
bool MariaDBServer::redirect_one_slave(const string& change_cmd)
|
||||
|
@ -261,14 +261,16 @@ public:
|
||||
const SlaveStatus* slave_connection_status_host_port(const MariaDBServer* target) const;
|
||||
|
||||
/**
|
||||
* Checks if this server can replicate from master. Only considers gtid:s and only detects obvious errors.
|
||||
* The non-detected errors will mostly be detected once the slave tries to start replicating.
|
||||
* Checks if this server can replicate from master. Only considers gtid:s and only detects obvious
|
||||
* errors. The non-detected errors will mostly be detected once the slave tries to start replicating.
|
||||
* Before calling this, update the gtid:s of the master so that the the gtid:s of the master are more
|
||||
* recent than those of this server.
|
||||
*
|
||||
* @param master_info Master server
|
||||
* @param error_out Details the reason for a negative result
|
||||
* @param reason_out Details the reason for a negative result
|
||||
* @return True if slave can replicate from master
|
||||
*/
|
||||
bool can_replicate_from(MariaDBServer* master, std::string* error_out);
|
||||
bool can_replicate_from(MariaDBServer* master, std::string* reason_out);
|
||||
|
||||
/**
|
||||
* Redirect one slave server to another master
|
||||
|
Loading…
x
Reference in New Issue
Block a user