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;
|
bool rval = false;
|
||||||
auto result = execute_query(query, errmsg_out);
|
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);
|
rval = true;
|
||||||
auto binlog_str = result->get_string(i_binlog_pos);
|
if (result->next_row())
|
||||||
bool current_ok = false;
|
|
||||||
if (current_str.empty())
|
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
m_gtid_current_pos = GtidList::from_string(current_str);
|
// Query succeeded but returned 0 rows. This means that the server has no gtid:s.
|
||||||
current_ok = !m_gtid_current_pos.empty();
|
m_gtid_current_pos = GtidList();
|
||||||
}
|
|
||||||
|
|
||||||
if (binlog_str.empty())
|
|
||||||
{
|
|
||||||
m_gtid_binlog_pos = GtidList();
|
m_gtid_binlog_pos = GtidList();
|
||||||
}
|
}
|
||||||
else
|
} // If query failed, do not update gtid:s.
|
||||||
{
|
|
||||||
m_gtid_binlog_pos = GtidList::from_string(binlog_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
rval = current_ok;
|
|
||||||
}
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ public:
|
|||||||
* Query gtid_current_pos and gtid_binlog_pos and save the values to the server.
|
* 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.
|
* @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);
|
bool update_gtids(std::string* errmsg_out = NULL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user