MXS-1865 Update server version only when (re)connecting
Updating it every iteration is needless.
This commit is contained in:
@ -57,7 +57,7 @@ void update_server_status(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *database)
|
||||
/** Try to connect to or ping the database */
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(monitor, database);
|
||||
|
||||
if (rval == MONITOR_CONN_OK)
|
||||
if (mon_connection_is_ok(rval))
|
||||
{
|
||||
server_set_status_nolock(&temp_server, SERVER_RUNNING);
|
||||
MYSQL_RES *result;
|
||||
|
@ -355,7 +355,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
|
||||
database->mon_prev_status = database->server->status;
|
||||
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(mon, database);
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
if (!mon_connection_is_ok(rval))
|
||||
{
|
||||
if (mysql_errno(database->con) == ER_ACCESS_DENIED_ERROR)
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ static void update_server_status(MXS_MONITOR* monitor, MXS_MONITORED_SERVER* ser
|
||||
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(monitor, server);
|
||||
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
if (!mon_connection_is_ok(rval))
|
||||
{
|
||||
if (mysql_errno(server->con) == ER_ACCESS_DENIED_ERROR)
|
||||
{
|
||||
|
@ -453,7 +453,7 @@ void MariaDBMonitor::check_maxscale_schema_replication()
|
||||
while (database)
|
||||
{
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(m_monitor_base, database);
|
||||
if (rval == MONITOR_CONN_OK)
|
||||
if (mon_connection_is_ok(rval))
|
||||
{
|
||||
if (!check_replicate_ignore_table(database) ||
|
||||
!check_replicate_do_table(database) ||
|
||||
|
@ -685,10 +685,18 @@ void MariaDBServer::monitor_server(MXS_MONITOR* base_monitor)
|
||||
|
||||
SERVER* srv = mon_srv->server;
|
||||
MYSQL* conn = mon_srv->con; // mon_ping_or_connect_to_db() may have reallocated the MYSQL struct.
|
||||
if (rval == MONITOR_CONN_OK)
|
||||
if (mon_connection_is_ok(rval))
|
||||
{
|
||||
server_clear_status_nolock(srv, SERVER_AUTH_ERROR);
|
||||
monitor_clear_pending_status(mon_srv, SERVER_AUTH_ERROR);
|
||||
/* Store current status in both server and monitor server pending struct */
|
||||
server_set_status_nolock(srv, SERVER_RUNNING);
|
||||
monitor_set_pending_status(mon_srv, SERVER_RUNNING);
|
||||
|
||||
if (rval == MONITOR_CONN_NEWCONN_OK)
|
||||
{
|
||||
update_server_info();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -713,39 +721,6 @@ void MariaDBServer::monitor_server(MXS_MONITOR* base_monitor)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Store current status in both server and monitor server pending struct */
|
||||
server_set_status_nolock(srv, SERVER_RUNNING);
|
||||
monitor_set_pending_status(mon_srv, SERVER_RUNNING);
|
||||
|
||||
/* Check whether current server is MaxScale Binlog Server */
|
||||
MYSQL_RES *result;
|
||||
if (mxs_mysql_query(conn, "SELECT @@maxscale_version") == 0 &&
|
||||
(result = mysql_store_result(conn)) != NULL)
|
||||
{
|
||||
m_binlog_relay = true;
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_binlog_relay = false;
|
||||
}
|
||||
|
||||
/* Get server version string, also get/set numeric representation. */
|
||||
mxs_mysql_set_server_version(conn, srv);
|
||||
/* Set monitor version enum. */
|
||||
uint64_t version_num = server_get_version(srv);
|
||||
if (version_num >= 100000)
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_100;
|
||||
}
|
||||
else if (version_num >= 5 * 10000 + 5 * 100)
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_55;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_UNKNOWN;
|
||||
}
|
||||
/* Query a few settings. */
|
||||
read_server_variables();
|
||||
/* If gtid domain exists and server is 10.0, update gtid:s */
|
||||
@ -790,6 +765,45 @@ void MariaDBServer::update_slave_status()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update information which changes rarely. This method should be called after (re)connecting to a backend.
|
||||
* Calling this every monitoring loop is overkill.
|
||||
*/
|
||||
void MariaDBServer::update_server_info()
|
||||
{
|
||||
auto conn = m_server_base->con;
|
||||
// Check whether this server is a MaxScale Binlog Server.
|
||||
MYSQL_RES *result;
|
||||
if (mxs_mysql_query(conn, "SELECT @@maxscale_version") == 0 &&
|
||||
(result = mysql_store_result(conn)) != NULL)
|
||||
{
|
||||
m_binlog_relay = true;
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_binlog_relay = false;
|
||||
}
|
||||
|
||||
/* Get server version string, also get/set numeric representation. These functions do not actually
|
||||
* query the server, since the data was obtained when connecting. */
|
||||
mxs_mysql_set_server_version(conn, m_server_base->server);
|
||||
/* Set monitor version enum. */
|
||||
uint64_t version_num = server_get_version(m_server_base->server);
|
||||
if (version_num >= 100000)
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_100;
|
||||
}
|
||||
else if (version_num >= 5 * 10000 + 5 * 100)
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_55;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_version = MariaDBServer::MARIADB_VERSION_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
SlaveStatus::slave_io_running_t SlaveStatus::slave_io_from_string(const std::string& str)
|
||||
{
|
||||
slave_io_running_t rval = SLAVE_IO_NO;
|
||||
|
@ -295,6 +295,7 @@ public:
|
||||
private:
|
||||
void monitor_server(MXS_MONITOR* base_monitor);
|
||||
void update_slave_status();
|
||||
void update_server_info();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -259,7 +259,7 @@ monitorDatabase(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database)
|
||||
database->mon_prev_status = database->server->status;
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(mon, database);
|
||||
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
if (!mon_connection_is_ok(rval))
|
||||
{
|
||||
if (mysql_errno(database->con) == ER_ACCESS_DENIED_ERROR)
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ monitorDatabase(MXS_MONITORED_SERVER *database, char *defaultUser, char *default
|
||||
}
|
||||
|
||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(mon, database);
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
if (!mon_connection_is_ok(rval))
|
||||
{
|
||||
server_clear_status_nolock(database->server, SERVER_RUNNING);
|
||||
|
||||
|
Reference in New Issue
Block a user