MXS-2158 Return true if update_gtids() succeeds, even if no data is returned
Previously, if the server had no gtid:s, the method would fail leading to a confusing error message. This could even totally stop the monitor from working if a recent server version (10.X) did not have any gtid events.
This commit is contained in:
parent
f03c5e0fef
commit
14e38e4e08
@ -376,32 +376,39 @@ bool MariaDBServer::update_gtids(string* errmsg_out)
|
||||
|
||||
bool rval = false;
|
||||
auto result = execute_query(query, errmsg_out);
|
||||
if (result.get() != NULL && result->next_row())
|
||||
if (result.get() != NULL)
|
||||
{
|
||||
auto current_str = result->get_string(i_current_pos);
|
||||
auto binlog_str = result->get_string(i_binlog_pos);
|
||||
bool current_ok = false;
|
||||
if (current_str.empty())
|
||||
rval = true;
|
||||
if (result->next_row())
|
||||
{
|
||||
m_gtid_current_pos = GtidList();
|
||||
// Query returned at least some data.
|
||||
auto current_str = result->get_string(i_current_pos);
|
||||
auto binlog_str = result->get_string(i_binlog_pos);
|
||||
if (current_str.empty())
|
||||
{
|
||||
m_gtid_current_pos = GtidList();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gtid_current_pos = GtidList::from_string(current_str);
|
||||
}
|
||||
|
||||
if (binlog_str.empty())
|
||||
{
|
||||
m_gtid_binlog_pos = GtidList();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gtid_binlog_pos = GtidList::from_string(binlog_str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gtid_current_pos = GtidList::from_string(current_str);
|
||||
current_ok = !m_gtid_current_pos.empty();
|
||||
}
|
||||
|
||||
if (binlog_str.empty())
|
||||
{
|
||||
// Query succeeded but returned 0 rows. This means that the server has no gtid:s.
|
||||
m_gtid_current_pos = GtidList();
|
||||
m_gtid_binlog_pos = GtidList();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gtid_binlog_pos = GtidList::from_string(binlog_str);
|
||||
}
|
||||
|
||||
rval = current_ok;
|
||||
}
|
||||
} // If query failed, do not update gtid:s.
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
||||
* Query gtid_current_pos and gtid_binlog_pos and save the values to the server.
|
||||
*
|
||||
* @param errmsg_out Where to store an error message if query fails. Can be null.
|
||||
* @return True if successful
|
||||
* @return True if query succeeded
|
||||
*/
|
||||
bool update_gtids(std::string* errmsg_out = NULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user