MXS-1367: Take mxs_mysql_query into use
The use of a wrapper function allows automated retrying of the queries without requiring any changes to the code that uses it.
This commit is contained in:
parent
f1f8a4b5b2
commit
67ef7bd058
@ -700,7 +700,7 @@ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (mysql_query(mondb->con, query) != 0)
|
||||
else if (mxs_mysql_query(mondb->con, query) != 0)
|
||||
{
|
||||
switch (mysql_errno(mondb->con))
|
||||
{
|
||||
|
@ -615,7 +615,7 @@ int gssapi_auth_load_users(SERV_LISTENER *listener)
|
||||
|
||||
if (mxs_mysql_real_connect(mysql, servers->server, user, pw))
|
||||
{
|
||||
if (mysql_query(mysql, gssapi_users_query))
|
||||
if (mxs_mysql_query(mysql, gssapi_users_query))
|
||||
{
|
||||
MXS_ERROR("Failed to query server '%s' for GSSAPI users: %s",
|
||||
servers->server->unique_name, mysql_error(mysql));
|
||||
|
@ -538,7 +538,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
bool rval = true;
|
||||
sprintf(query, template, query_pw);
|
||||
|
||||
if (mysql_query(mysql, query) != 0)
|
||||
if (mxs_mysql_query(mysql, query) != 0)
|
||||
{
|
||||
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
@ -568,7 +568,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql_query(mysql, "SELECT user, host, db FROM mysql.db limit 1") != 0)
|
||||
if (mxs_mysql_query(mysql, "SELECT user, host, db FROM mysql.db limit 1") != 0)
|
||||
{
|
||||
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
@ -596,7 +596,7 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql_query(mysql, "SELECT user, host, db FROM mysql.tables_priv limit 1") != 0)
|
||||
if (mxs_mysql_query(mysql, "SELECT user, host, db FROM mysql.tables_priv limit 1") != 0)
|
||||
{
|
||||
if (mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
@ -747,7 +747,7 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server, SERVICE *service, SERV
|
||||
|
||||
if (query)
|
||||
{
|
||||
if (mysql_query(con, query) == 0)
|
||||
if (mxs_mysql_query(con, query) == 0)
|
||||
{
|
||||
MYSQL_RES *result = mysql_store_result(con);
|
||||
|
||||
@ -801,7 +801,7 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server, SERVICE *service, SERV
|
||||
}
|
||||
|
||||
/** Load the list of databases */
|
||||
if (mysql_query(con, "SHOW DATABASES") == 0)
|
||||
if (mxs_mysql_query(con, "SHOW DATABASES") == 0)
|
||||
{
|
||||
MYSQL_RES *result = mysql_store_result(con);
|
||||
if (result)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <mysqld_error.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/debug.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
|
||||
typedef struct aurora_monitor
|
||||
{
|
||||
@ -59,9 +60,9 @@ void update_server_status(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *database)
|
||||
MYSQL_RES *result;
|
||||
|
||||
/** Connection is OK, query for replica status */
|
||||
if (mysql_query(database->con, "SELECT @@aurora_server_id, server_id FROM "
|
||||
"information_schema.replica_host_status "
|
||||
"WHERE session_id = 'MASTER_SESSION_ID'") == 0 &&
|
||||
if (mxs_mysql_query(database->con, "SELECT @@aurora_server_id, server_id FROM "
|
||||
"information_schema.replica_host_status "
|
||||
"WHERE session_id = 'MASTER_SESSION_ID'") == 0 &&
|
||||
(result = mysql_store_result(database->con)))
|
||||
{
|
||||
ss_dassert(mysql_field_count(database->con) == 2);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "galeramon.h"
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
|
||||
#define DONOR_NODE_NAME_MAX_LEN 60
|
||||
#define DONOR_LIST_SET_VAR "SET GLOBAL wsrep_sst_donor = \""
|
||||
@ -269,7 +270,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
}
|
||||
|
||||
/* Check if the the Galera FSM shows this node is joined to the cluster */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
@ -290,7 +291,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
/* Check if the node is a donor and is using xtrabackup, in this case it can stay alive */
|
||||
else if (strcmp(row[1], "2") == 0 && handle->availableWhenDonor == 1)
|
||||
{
|
||||
if (mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0
|
||||
&& (result2 = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
@ -327,7 +328,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
if (isjoined)
|
||||
{
|
||||
/* Check the the Galera node index in the cluster */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_index'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_index'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
@ -772,7 +773,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
MXS_MONITOR_SERVERS *ptr = node_list[k];
|
||||
|
||||
/* Get the Galera node name */
|
||||
if (mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0
|
||||
if (mxs_mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0
|
||||
&& (result = mysql_store_result(ptr->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(ptr->con) < 2)
|
||||
@ -817,7 +818,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = node_list[k];
|
||||
/* Set the Galera SST donor node list */
|
||||
if (mysql_query(ptr->con, donor_list) == 0)
|
||||
if (mxs_mysql_query(ptr->con, donor_list) == 0)
|
||||
{
|
||||
MXS_DEBUG("SET GLOBAL rep_sst_donor OK in node %s",
|
||||
ptr->server->unique_name);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "mmmon.h"
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
|
||||
static void monitorMain(void *);
|
||||
|
||||
@ -258,7 +259,7 @@ monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
}
|
||||
|
||||
/* get server_id form current node */
|
||||
if (mysql_query(database->con, "SELECT @@server_id") == 0
|
||||
if (mxs_mysql_query(database->con, "SELECT @@server_id") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long server_id = -1;
|
||||
@ -295,7 +296,7 @@ monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
if (server_version >= 100000)
|
||||
{
|
||||
|
||||
if (mysql_query(database->con, "SHOW ALL SLAVES STATUS") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW ALL SLAVES STATUS") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
int i = 0;
|
||||
@ -358,7 +359,7 @@ monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mysql_query(database->con, "SHOW SLAVE STATUS") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW SLAVE STATUS") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long master_id = -1;
|
||||
@ -423,7 +424,7 @@ monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
}
|
||||
|
||||
/* get variable 'read_only' set by an external component */
|
||||
if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <maxscale/modutil.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/debug.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
|
||||
/** Column positions for SHOW SLAVE STATUS */
|
||||
#define MYSQL55_STATUS_BINLOG_POS 5
|
||||
@ -405,7 +406,7 @@ static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_
|
||||
|
||||
MYSQL_RES* result;
|
||||
|
||||
if (mysql_query(database->con, query) == 0
|
||||
if (mxs_mysql_query(database->con, query) == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < columns)
|
||||
@ -521,7 +522,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
||||
int nslaves = 0;
|
||||
if (database->con)
|
||||
{
|
||||
if (mysql_query(database->con, "SHOW SLAVE HOSTS") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW SLAVE HOSTS") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 4)
|
||||
@ -697,7 +698,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
ss_dassert(serv_info);
|
||||
|
||||
/* Get server_id and read_only from current node */
|
||||
if (mysql_query(database->con, "SELECT @@server_id, @@read_only") == 0
|
||||
if (mxs_mysql_query(database->con, "SELECT @@server_id, @@read_only") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long server_id = -1;
|
||||
@ -1476,8 +1477,8 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
}
|
||||
|
||||
/* check if the maxscale_schema database and replication_heartbeat table exist */
|
||||
if (mysql_query(database->con, "SELECT table_name FROM information_schema.tables "
|
||||
"WHERE table_schema = 'maxscale_schema' AND table_name = 'replication_heartbeat'"))
|
||||
if (mxs_mysql_query(database->con, "SELECT table_name FROM information_schema.tables "
|
||||
"WHERE table_schema = 'maxscale_schema' AND table_name = 'replication_heartbeat'"))
|
||||
{
|
||||
MXS_ERROR( "Error checking for replication_heartbeat in Master server"
|
||||
": %s", mysql_error(database->con));
|
||||
@ -1499,13 +1500,13 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
if (0 == returned_rows)
|
||||
{
|
||||
/* create repl_heartbeat table in maxscale_schema database */
|
||||
if (mysql_query(database->con, "CREATE TABLE IF NOT EXISTS "
|
||||
"maxscale_schema.replication_heartbeat "
|
||||
"(maxscale_id INT NOT NULL, "
|
||||
"master_server_id INT NOT NULL, "
|
||||
"master_timestamp INT UNSIGNED NOT NULL, "
|
||||
"PRIMARY KEY ( master_server_id, maxscale_id ) ) "
|
||||
"ENGINE=MYISAM DEFAULT CHARSET=latin1"))
|
||||
if (mxs_mysql_query(database->con, "CREATE TABLE IF NOT EXISTS "
|
||||
"maxscale_schema.replication_heartbeat "
|
||||
"(maxscale_id INT NOT NULL, "
|
||||
"master_server_id INT NOT NULL, "
|
||||
"master_timestamp INT UNSIGNED NOT NULL, "
|
||||
"PRIMARY KEY ( master_server_id, maxscale_id ) ) "
|
||||
"ENGINE=MYISAM DEFAULT CHARSET=latin1"))
|
||||
{
|
||||
MXS_ERROR("Error creating maxscale_schema.replication_heartbeat "
|
||||
"table in Master server: %s", mysql_error(database->con));
|
||||
@ -1520,7 +1521,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
sprintf(heartbeat_purge_query,
|
||||
"DELETE FROM maxscale_schema.replication_heartbeat WHERE master_timestamp < %lu", purge_time);
|
||||
|
||||
if (mysql_query(database->con, heartbeat_purge_query))
|
||||
if (mxs_mysql_query(database->con, heartbeat_purge_query))
|
||||
{
|
||||
MXS_ERROR("Error deleting from maxscale_schema.replication_heartbeat "
|
||||
"table: [%s], %s",
|
||||
@ -1538,7 +1539,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
heartbeat, handle->master->server->node_id, id);
|
||||
|
||||
/* Try to insert MaxScale timestamp into master */
|
||||
if (mysql_query(database->con, heartbeat_insert_query))
|
||||
if (mxs_mysql_query(database->con, heartbeat_insert_query))
|
||||
{
|
||||
|
||||
database->server->rlag = MAX_RLAG_NOT_AVAILABLE;
|
||||
@ -1556,7 +1557,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
"REPLACE INTO maxscale_schema.replication_heartbeat (master_server_id, maxscale_id, master_timestamp ) VALUES ( %li, %lu, %lu)",
|
||||
handle->master->server->node_id, id, heartbeat);
|
||||
|
||||
if (mysql_query(database->con, heartbeat_insert_query))
|
||||
if (mxs_mysql_query(database->con, heartbeat_insert_query))
|
||||
{
|
||||
|
||||
database->server->rlag = MAX_RLAG_NOT_AVAILABLE;
|
||||
@ -1617,7 +1618,7 @@ static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
id, handle->master->server->node_id);
|
||||
|
||||
/* if there is a master then send the query to the slave with master_id */
|
||||
if (handle->master != NULL && (mysql_query(database->con, select_heartbeat_query) == 0
|
||||
if (handle->master != NULL && (mxs_mysql_query(database->con, select_heartbeat_query) == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL))
|
||||
{
|
||||
int rows_found = 0;
|
||||
@ -1886,8 +1887,8 @@ bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
|
||||
if (mysql_query(database->con,
|
||||
"show variables like 'replicate_ignore_table'") == 0 &&
|
||||
if (mxs_mysql_query(database->con,
|
||||
"show variables like 'replicate_ignore_table'") == 0 &&
|
||||
(result = mysql_store_result(database->con)) &&
|
||||
mysql_num_fields(result) > 1)
|
||||
{
|
||||
@ -1930,8 +1931,8 @@ bool check_replicate_do_table(MXS_MONITOR_SERVERS* database)
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
|
||||
if (mysql_query(database->con,
|
||||
"show variables like 'replicate_do_table'") == 0 &&
|
||||
if (mxs_mysql_query(database->con,
|
||||
"show variables like 'replicate_do_table'") == 0 &&
|
||||
(result = mysql_store_result(database->con)) &&
|
||||
mysql_num_fields(result) > 1)
|
||||
{
|
||||
@ -1973,8 +1974,8 @@ bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database)
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
|
||||
if (mysql_query(database->con,
|
||||
"show variables like 'replicate_wild_do_table'") == 0 &&
|
||||
if (mxs_mysql_query(database->con,
|
||||
"show variables like 'replicate_wild_do_table'") == 0 &&
|
||||
(result = mysql_store_result(database->con)) &&
|
||||
mysql_num_fields(result) > 1)
|
||||
{
|
||||
@ -2020,8 +2021,8 @@ bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
|
||||
if (mysql_query(database->con,
|
||||
"show variables like 'replicate_wild_ignore_table'") == 0 &&
|
||||
if (mxs_mysql_query(database->con,
|
||||
"show variables like 'replicate_wild_ignore_table'") == 0 &&
|
||||
(result = mysql_store_result(database->con)) &&
|
||||
mysql_num_fields(result) > 1)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "../mysqlmon.h"
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
|
||||
static void monitorMain(void *);
|
||||
|
||||
@ -224,7 +225,7 @@ monitorDatabase(MXS_MONITOR_SERVERS *database, char *defaultUser, char *defaultP
|
||||
}
|
||||
|
||||
/* Check if the the SQL node is able to contact one or more data nodes */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
@ -251,7 +252,7 @@ monitorDatabase(MXS_MONITOR_SERVERS *database, char *defaultUser, char *defaultP
|
||||
}
|
||||
|
||||
/* Check the the SQL node id in the MySQL cluster */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
|
||||
if (mxs_mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if (mysql_field_count(database->con) < 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user