From 071d364b0ae4847a68d29e704cb834633646401c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 28 Sep 2017 15:04:33 +0300 Subject: [PATCH 1/7] Fix formatting errors Fixed the formatting errors introduced by Astyle. Changed the comment syntax to use a more Astyle-friendly one. --- server/core/dcb.cc | 4 ++-- server/modules/filter/cache/test/testrules.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 955df0de3..41aa75638 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -1157,8 +1157,8 @@ void dcb_final_close(DCB* dcb) if (dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER && // Backend DCB dcb->state == DCB_STATE_POLLING && // Being polled - dcb->persistentstart == 0 && // Not already in (> 0) or being evicted from (-1) - // the persistent pool. + dcb->persistentstart == 0 && /** Not already in (> 0) or being evicted from (-1) + * the persistent pool. */ dcb->server) // And has a server { /* May be a candidate for persistence, so save user name */ diff --git a/server/modules/filter/cache/test/testrules.cc b/server/modules/filter/cache/test/testrules.cc index a0e307fc7..21195bad7 100644 --- a/server/modules/filter/cache/test/testrules.cc +++ b/server/modules/filter/cache/test/testrules.cc @@ -66,14 +66,14 @@ struct user_test_case const struct user_test_case user_test_cases[] = { - USER_TEST_CASE( =, bob, CACHE_OP_LIKE, bob@.*), - USER_TEST_CASE( =, 'bob', CACHE_OP_LIKE, bob@.*), - USER_TEST_CASE( =, bob@ %, CACHE_OP_LIKE, bob@.*), - USER_TEST_CASE( =, 'bob'@'%.52', CACHE_OP_LIKE, bob@.*\\.52), - USER_TEST_CASE( =, bob@127.0.0.1, CACHE_OP_EQ, bob@127.0.0.1), - USER_TEST_CASE( =, b*b@127.0.0.1, CACHE_OP_EQ, b*b@127.0.0.1), - USER_TEST_CASE( =, b*b@ % .0.0.1, CACHE_OP_LIKE, b\\*b@.*\\.0\\.0\\.1), - USER_TEST_CASE( =, b*b@ % .0. % .1, CACHE_OP_LIKE, b\\*b@.*\\.0\\..*\\.1), + USER_TEST_CASE(=, bob, CACHE_OP_LIKE, bob@.*), + USER_TEST_CASE(=, 'bob', CACHE_OP_LIKE, bob@.*), + USER_TEST_CASE(=, bob@%, CACHE_OP_LIKE, bob@.*), + USER_TEST_CASE(=, 'bob'@'%.52', CACHE_OP_LIKE, bob@.*\\.52), + USER_TEST_CASE(=, bob@127.0.0.1, CACHE_OP_EQ, bob@127.0.0.1), + USER_TEST_CASE(=, b*b@127.0.0.1, CACHE_OP_EQ, b*b@127.0.0.1), + USER_TEST_CASE(=, b*b@%.0.0.1, CACHE_OP_LIKE, b\\*b@.*\\.0\\.0\\.1), + USER_TEST_CASE(=, b*b@%.0.%.1, CACHE_OP_LIKE, b\\*b@.*\\.0\\..*\\.1), }; const size_t n_user_test_cases = sizeof(user_test_cases) / sizeof(user_test_cases[0]); From ae3e7a07e200877a9140e0d2c549750ec88e8cde Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 29 Sep 2017 09:56:50 +0300 Subject: [PATCH 2/7] Always return json object from module commands If a module command returns a json object, it will always be returned to the caller, irrespective of whether the command itself succeeded or not. Otherwise, if the command failed and if the module command has set an error message, that error message will be returned as a json object containing the error message. --- server/core/modulecmd.cc | 14 ++++++++------ server/modules/routing/debugcli/debugcmd.c | 20 +++++++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/server/core/modulecmd.cc b/server/core/modulecmd.cc index d8c96f55f..e2c3fab14 100644 --- a/server/core/modulecmd.cc +++ b/server/core/modulecmd.cc @@ -541,6 +541,12 @@ void modulecmd_arg_free(MODULECMD_ARG* arg) } } +static void modulecmd_clear_error() +{ + prepare_error(); + errbuf[0] = '\0'; +} + bool modulecmd_call_command(const MODULECMD *cmd, const MODULECMD_ARG *args, json_t** output) { bool rval = false; @@ -557,6 +563,8 @@ bool modulecmd_call_command(const MODULECMD *cmd, const MODULECMD_ARG *args, jso args = &MODULECMD_NO_ARGUMENTS; } + modulecmd_clear_error(); + json_t* discard = NULL; rval = cmd->func(args, output ? output : &discard); json_decref(discard); @@ -575,12 +583,6 @@ void modulecmd_set_error(const char *format, ...) va_end(list); } -static void modulecmd_clear_error() -{ - prepare_error(); - errbuf[0] = '\0'; -} - const char* modulecmd_get_error() { prepare_error(); diff --git a/server/modules/routing/debugcli/debugcmd.c b/server/modules/routing/debugcli/debugcmd.c index afd2eb821..737425267 100644 --- a/server/modules/routing/debugcli/debugcmd.c +++ b/server/modules/routing/debugcli/debugcmd.c @@ -1677,13 +1677,23 @@ static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3, { json_t* output = NULL; - if (!modulecmd_call_command(cmd, arg, &output)) + bool succeeded = modulecmd_call_command(cmd, arg, &output); + + if (!succeeded && !output) { - const char* err = modulecmd_get_error(); - dcb_printf(dcb, "Error: %s\n", *err ? err : - "Call to module command failed, see log file for more details"); + const char* s = modulecmd_get_error(); + ss_dassert(s); + + if (*s == 0) + { + // No error had been set, so we add a default one. + modulecmd_set_error("%s", "Call to module command failed, see log file for more details."); + } + + output = modulecmd_get_json_error(); } - else if (output) + + if (output) { char* js = json_dumps(output, JSON_INDENT(4)); dcb_printf(dcb, "%s\n", js); From c6623337b6e09ed53f255e5c8c9a1f307458e46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 29 Sep 2017 10:03:43 +0300 Subject: [PATCH 3/7] Stop monitors first when shutting down As monitors aren't synchronized with the worker threads, they need to be shut down first. --- server/core/gateway.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 7a3b14834..650e91861 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -2081,6 +2081,9 @@ int main(int argc, char **argv) /** Stop administrative interface */ mxs_admin_shutdown(); + /*< Stop all the monitors */ + monitorStopAll(); + /*< * Wait for the housekeeper to finish. */ @@ -2110,9 +2113,6 @@ int main(int argc, char **argv) */ thread_wait(log_flush_thr); - /*< Stop all the monitors */ - monitorStopAll(); - /*< Call finish on all modules. */ modules_process_finish(); From b446f442b6460cb089c4e187770802c5249ce91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 29 Sep 2017 10:30:00 +0300 Subject: [PATCH 4/7] Process data sent before authentication is complete If the client sends data before authentication is complete, it must not be discarded and it needs to be processed like as if it was sent in a separate network packet. --- .../protocol/MySQL/MySQLClient/mysql_client.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc b/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc index 43e7f0f6b..08fa291de 100644 --- a/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc +++ b/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc @@ -497,15 +497,18 @@ int gw_read_client_event(DCB* dcb) */ case MXS_AUTH_STATE_MESSAGE_READ: /* After this call read_buffer will point to freed data */ + dcb_readq_set(dcb, read_buffer); if (nbytes_read < 3 || (0 == max_bytes && nbytes_read < (int)(MYSQL_GET_PAYLOAD_LEN((uint8_t *) GWBUF_DATA(read_buffer)) + 4)) || (0 != max_bytes && nbytes_read < max_bytes)) { - - dcb_readq_set(dcb, read_buffer); - return 0; } + + read_buffer = modutil_get_next_MySQL_packet(&dcb->readq); + ss_dassert(read_buffer); + nbytes_read = gwbuf_length(read_buffer); + return_code = gw_read_do_authentication(dcb, read_buffer, nbytes_read); break; @@ -713,6 +716,12 @@ gw_read_do_authentication(DCB *dcb, GWBUF *read_buffer, int nbytes_read) ss_debug(bool check = ) mxs_worker_register_session(session); ss_dassert(check); mxs_mysql_send_ok(dcb, next_sequence, 0, NULL); + + if (dcb->readq) + { + // The user has already send more data, process it + poll_fake_read_event(dcb); + } } else { From 27ccf0877c8577361fbdcc4de2b2e8dddb06d9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 29 Sep 2017 10:59:45 +0300 Subject: [PATCH 5/7] Fix bug in the cdc_connector The cdc_connector did not check if the data request was successful. --- .../cdc_connector/cdc_connector.cpp | 20 ++++++++++++++++++- .../cdc_connector/cdc_connector.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/maxscale-system-test/cdc_connector/cdc_connector.cpp b/maxscale-system-test/cdc_connector/cdc_connector.cpp index 407b3564d..5f497f220 100644 --- a/maxscale-system-test/cdc_connector/cdc_connector.cpp +++ b/maxscale-system-test/cdc_connector/cdc_connector.cpp @@ -213,6 +213,20 @@ bool Connection::requestData(const std::string& table, const std::string& gtid) m_error = "Failed to write request: "; m_error += strerror_r(errno, err, sizeof (err)); } + else + { + // Read the first row to know if data request was successful + Row row = read(); + + if (row) + { + m_first_row = row; + } + else + { + rval = false; + } + } return rval; } @@ -288,7 +302,11 @@ Row Connection::read() Row rval; std::string row; - if (readRow(row)) + if (m_first_row) + { + rval.swap(m_first_row); + } + else if (readRow(row)) { json_error_t err; json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err); diff --git a/maxscale-system-test/cdc_connector/cdc_connector.h b/maxscale-system-test/cdc_connector/cdc_connector.h index 42b9c57f7..f0f8833f1 100644 --- a/maxscale-system-test/cdc_connector/cdc_connector.h +++ b/maxscale-system-test/cdc_connector/cdc_connector.h @@ -52,6 +52,7 @@ private: std::string m_schema; ValueList m_keys; ValueList m_types; + Row m_first_row; bool doAuth(); bool doRegistration(); From 8d03876e3e0060b49348f197d3e308ddbd5248ab Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 2 Oct 2017 15:01:56 +0300 Subject: [PATCH 6/7] Rename MXS_MONITOR_SERVERS to MXS_MONITORED_SERVER An element in a linked list is not a list. --- include/maxscale/monitor.h | 26 ++--- server/core/monitor.cc | 100 +++++++++--------- server/modules/monitor/auroramon/auroramon.c | 4 +- server/modules/monitor/galeramon/galeramon.c | 42 ++++---- server/modules/monitor/galeramon/galeramon.h | 2 +- server/modules/monitor/grmon/grmon.cc | 22 ++-- server/modules/monitor/mmmon/mmmon.c | 12 +-- server/modules/monitor/mmmon/mmmon.h | 2 +- server/modules/monitor/mysqlmon.h | 2 +- server/modules/monitor/mysqlmon/mysql_mon.cc | 72 ++++++------- .../monitor/ndbclustermon/ndbclustermon.c | 4 +- 11 files changed, 144 insertions(+), 144 deletions(-) diff --git a/include/maxscale/monitor.h b/include/maxscale/monitor.h index a50b73b10..5a75a9fd6 100644 --- a/include/maxscale/monitor.h +++ b/include/maxscale/monitor.h @@ -161,7 +161,7 @@ typedef enum /** * The linked list of servers that are being monitored by the monitor module. */ -typedef struct monitor_servers +typedef struct monitored_server { SERVER *server; /**< The server being monitored */ MYSQL *con; /**< The MySQL connection */ @@ -169,8 +169,8 @@ typedef struct monitor_servers int mon_err_count; unsigned int mon_prev_status; unsigned int pending_status; /**< Pending Status flag bitmap */ - struct monitor_servers *next; /**< The next server in the list */ -} MXS_MONITOR_SERVERS; + struct monitored_server *next; /**< The next server in the list */ +} MXS_MONITORED_SERVER; /** * Representation of the running monitor. @@ -182,7 +182,7 @@ struct mxs_monitor char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */ SPINLOCK lock; MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */ - MXS_MONITOR_SERVERS* databases; /*< List of databases the monitor monitors */ + MXS_MONITORED_SERVER* databases; /*< List of databases the monitor monitors */ monitor_state_t state; /**< The state of the monitor */ int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */ int connect_attempts; /**< How many times a connection is attempted */ @@ -255,16 +255,16 @@ extern const char CN_EVENTS[]; bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query); -void monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit); -void monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit); +void monitor_clear_pending_status(MXS_MONITORED_SERVER *ptr, int bit); +void monitor_set_pending_status(MXS_MONITORED_SERVER *ptr, int bit); void servers_status_pending_to_current(MXS_MONITOR *monitor); void servers_status_current_to_pending(MXS_MONITOR *monitor); -bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv); -bool mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv); +bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv); +bool mon_print_fail_status(MXS_MONITORED_SERVER* mon_srv); -mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database); -void mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval); +mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database); +void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval); void lock_monitor_servers(MXS_MONITOR *monitor); void release_monitor_servers(MXS_MONITOR *monitor); @@ -295,7 +295,7 @@ void mon_hangup_failed_servers(MXS_MONITOR *monitor); * * @param db Database where the query failed */ -void mon_report_query_error(MXS_MONITOR_SERVERS* db); +void mon_report_query_error(MXS_MONITORED_SERVER* db); /** * @brief Convert monitor to JSON @@ -332,7 +332,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host); * @param monitor Monitor to journal * @param master The current master server or NULL if no master exists */ -void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master); +void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master); /** * @brief Load a journal of server states @@ -340,6 +340,6 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master); * @param monitor Monitor where journal is loaded * @param master Set to point to the current master */ -void load_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master); +void load_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master); MXS_END_DECLS diff --git a/server/core/monitor.cc b/server/core/monitor.cc index a82bedebe..5f549950a 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -76,7 +76,7 @@ const char CN_EVENTS[] = "events"; static MXS_MONITOR *allMonitors = NULL; static SPINLOCK monLock = SPINLOCK_INIT; -static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers); +static void monitor_server_free_all(MXS_MONITORED_SERVER *servers); static void remove_server_journal(MXS_MONITOR *monitor); static bool journal_is_stale(MXS_MONITOR *monitor, time_t max_age); @@ -253,7 +253,7 @@ monitorStop(MXS_MONITOR *monitor) monitor->module->stopMonitor(monitor); monitor->state = MONITOR_STATE_STOPPED; - MXS_MONITOR_SERVERS* db = monitor->databases; + MXS_MONITORED_SERVER* db = monitor->databases; while (db) { // TODO: Create a generic entry point for this or move it inside stopMonitor @@ -313,7 +313,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server) else { rval = true; - MXS_MONITOR_SERVERS *db = (MXS_MONITOR_SERVERS *)MXS_MALLOC(sizeof(MXS_MONITOR_SERVERS)); + MXS_MONITORED_SERVER *db = (MXS_MONITORED_SERVER *)MXS_MALLOC(sizeof(MXS_MONITORED_SERVER)); MXS_ABORT_IF_NULL(db); db->server = server; @@ -341,7 +341,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server) } else { - MXS_MONITOR_SERVERS *ptr = mon->databases; + MXS_MONITORED_SERVER *ptr = mon->databases; while (ptr->next != NULL) { ptr = ptr->next; @@ -359,7 +359,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server) return rval; } -static void monitor_server_free(MXS_MONITOR_SERVERS *tofree) +static void monitor_server_free(MXS_MONITORED_SERVER *tofree) { if (tofree) { @@ -375,11 +375,11 @@ static void monitor_server_free(MXS_MONITOR_SERVERS *tofree) * Free monitor server list * @param servers Servers to free */ -static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers) +static void monitor_server_free_all(MXS_MONITORED_SERVER *servers) { while (servers) { - MXS_MONITOR_SERVERS *tofree = servers; + MXS_MONITORED_SERVER *tofree = servers; servers = servers->next; monitor_server_free(tofree); } @@ -402,7 +402,7 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server) spinlock_acquire(&mon->lock); - MXS_MONITOR_SERVERS *ptr = mon->databases; + MXS_MONITORED_SERVER *ptr = mon->databases; if (ptr && ptr->server == server) { @@ -410,7 +410,7 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server) } else { - MXS_MONITOR_SERVERS *prev = ptr; + MXS_MONITORED_SERVER *prev = ptr; while (ptr) { @@ -522,7 +522,7 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor) const char *sep = ""; - for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) { dcb_printf(dcb, "%s[%s]:%d", sep, db->server->name, db->server->port); sep = ", "; @@ -793,7 +793,7 @@ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query) MXS_CONFIG* cnf = config_get_global_options(); bool rval = false; - for (MXS_MONITOR_SERVERS *mondb = monitor->databases; mondb; mondb = mondb->next) + for (MXS_MONITORED_SERVER *mondb = monitor->databases; mondb; mondb = mondb->next) { if (mon_ping_or_connect_to_db(monitor, mondb) != MONITOR_CONN_OK) { @@ -912,7 +912,7 @@ bool monitorRemoveParameter(MXS_MONITOR *monitor, const char *key) * @param bit The bit to clear for the server */ void -monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit) +monitor_set_pending_status(MXS_MONITORED_SERVER *ptr, int bit) { ptr->pending_status |= bit; } @@ -924,7 +924,7 @@ monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit) * @param bit The bit to clear for the server */ void -monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit) +monitor_clear_pending_status(MXS_MONITORED_SERVER *ptr, int bit) { ptr->pending_status &= ~bit; } @@ -936,7 +936,7 @@ monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit) * @param node The monitor server data for a particular server * @result monitor_event_t A monitor event (enum) */ -static mxs_monitor_event_t mon_get_event_type(MXS_MONITOR_SERVERS* node) +static mxs_monitor_event_t mon_get_event_type(MXS_MONITORED_SERVER* node) { typedef enum { @@ -1052,7 +1052,7 @@ static mxs_monitor_event_t mon_get_event_type(MXS_MONITOR_SERVERS* node) * @param node The monitor server data whose event is wanted * @result string The name of the monitor event for the server */ -static const char* mon_get_event_name(MXS_MONITOR_SERVERS* node) +static const char* mon_get_event_name(MXS_MONITORED_SERVER* node) { mxs_monitor_event_t event = mon_get_event_type(node); @@ -1075,7 +1075,7 @@ static const char* mon_get_event_name(MXS_MONITOR_SERVERS* node) * @param dest Destination where the string is appended, must be null terminated * @param len Length of @c dest */ -static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int len, int status) +static void mon_append_node_names(MXS_MONITORED_SERVER* servers, char* dest, int len, int status) { const char *separator = ""; char arr[MAX_SERVER_ADDRESS_LEN + 64]; // Some extra space for port and separator @@ -1106,7 +1106,7 @@ static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int * @param mon_srv The monitored server * @return true if status has changed or false */ -bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv) +bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv) { bool rval = false; @@ -1140,19 +1140,19 @@ bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv) * @return true if failed status can be logged or false */ bool -mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv) +mon_print_fail_status(MXS_MONITORED_SERVER* mon_srv) { return (SERVER_IS_DOWN(mon_srv->server) && mon_srv->mon_err_count == 0); } -static MXS_MONITOR_SERVERS* find_parent_node(MXS_MONITOR_SERVERS* servers, - MXS_MONITOR_SERVERS* target) +static MXS_MONITORED_SERVER* find_parent_node(MXS_MONITORED_SERVER* servers, + MXS_MONITORED_SERVER* target) { - MXS_MONITOR_SERVERS* rval = NULL; + MXS_MONITORED_SERVER* rval = NULL; if (target->server->master_id > 0) { - for (MXS_MONITOR_SERVERS* node = servers; node; node = node->next) + for (MXS_MONITORED_SERVER* node = servers; node; node = node->next) { if (node->server->node_id == target->server->master_id) { @@ -1165,8 +1165,8 @@ static MXS_MONITOR_SERVERS* find_parent_node(MXS_MONITOR_SERVERS* servers, return rval; } -static std::string child_nodes(MXS_MONITOR_SERVERS* servers, - MXS_MONITOR_SERVERS* parent) +static std::string child_nodes(MXS_MONITORED_SERVER* servers, + MXS_MONITORED_SERVER* parent) { std::stringstream ss; @@ -1174,7 +1174,7 @@ static std::string child_nodes(MXS_MONITOR_SERVERS* servers, { bool have_content = false; - for (MXS_MONITOR_SERVERS* node = servers; node; node = node->next) + for (MXS_MONITORED_SERVER* node = servers; node; node = node->next) { if (node->server->master_id == parent->server->node_id) { @@ -1199,7 +1199,7 @@ static std::string child_nodes(MXS_MONITOR_SERVERS* servers, * @param script Script to execute */ void -monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* script) +monitor_launch_script(MXS_MONITOR* mon, MXS_MONITORED_SERVER* ptr, const char* script) { char arg[strlen(script) + 1]; strcpy(arg, script); @@ -1223,7 +1223,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc if (externcmd_matches(cmd, "$PARENT")) { std::stringstream ss; - MXS_MONITOR_SERVERS* parent = find_parent_node(mon->databases, ptr); + MXS_MONITORED_SERVER* parent = find_parent_node(mon->databases, ptr); if (parent) { @@ -1352,7 +1352,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc * @return MONITOR_CONN_OK if the connection is OK, else the reason for the failure */ mxs_connect_result_t -mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database) +mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database) { /** Return if the connection is OK */ if (database->con && mysql_ping(database->con) == 0) @@ -1417,7 +1417,7 @@ mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database) * @param rval Return value of mon_connect_to_db */ void -mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval) +mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval) { MXS_ERROR(rval == MONITOR_CONN_TIMEOUT ? "Monitor timed out when connecting to server [%s]:%d : \"%s\"" : @@ -1426,7 +1426,7 @@ mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval) mysql_error(database->con)); } -static void mon_log_state_change(MXS_MONITOR_SERVERS *ptr) +static void mon_log_state_change(MXS_MONITORED_SERVER *ptr) { SERVER srv; srv.status = ptr->mon_prev_status; @@ -1451,7 +1451,7 @@ MXS_MONITOR* monitor_server_in_use(const SERVER *server) if (mon->active) { - for (MXS_MONITOR_SERVERS *db = mon->databases; db && !rval; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->databases; db && !rval; db = db->next) { if (db->server == server) { @@ -1495,7 +1495,7 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena if (monitor->databases) { dprintf(file, "%s=", CN_SERVERS); - for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) { if (db != monitor->databases) { @@ -1575,7 +1575,7 @@ bool monitor_serialize(const MXS_MONITOR *monitor) void mon_hangup_failed_servers(MXS_MONITOR *monitor) { - for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) { if (mon_status_changed(ptr) && (!(SERVER_IS_RUNNING(ptr->server)) || @@ -1586,7 +1586,7 @@ void mon_hangup_failed_servers(MXS_MONITOR *monitor) } } -void mon_report_query_error(MXS_MONITOR_SERVERS* db) +void mon_report_query_error(MXS_MONITORED_SERVER* db) { MXS_ERROR("Failed to execute query on server '%s' ([%s]:%d): %s", db->server->unique_name, db->server->name, @@ -1600,7 +1600,7 @@ void mon_report_query_error(MXS_MONITOR_SERVERS* db) */ void lock_monitor_servers(MXS_MONITOR *monitor) { - MXS_MONITOR_SERVERS *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->databases; while (ptr) { spinlock_acquire(&ptr->server->lock); @@ -1614,7 +1614,7 @@ void lock_monitor_servers(MXS_MONITOR *monitor) */ void release_monitor_servers(MXS_MONITOR *monitor) { - MXS_MONITOR_SERVERS *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->databases; while (ptr) { spinlock_release(&ptr->server->lock); @@ -1629,7 +1629,7 @@ void release_monitor_servers(MXS_MONITOR *monitor) */ void servers_status_pending_to_current(MXS_MONITOR *monitor) { - MXS_MONITOR_SERVERS *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->databases; while (ptr) { ptr->server->status = ptr->server->status_pending; @@ -1645,7 +1645,7 @@ void servers_status_pending_to_current(MXS_MONITOR *monitor) */ void servers_status_current_to_pending(MXS_MONITOR *monitor) { - MXS_MONITOR_SERVERS *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->databases; while (ptr) { ptr->server->status_pending = ptr->server->status; @@ -1655,7 +1655,7 @@ void servers_status_current_to_pending(MXS_MONITOR *monitor) void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events) { - for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) { if (mon_status_changed(ptr)) { @@ -1752,7 +1752,7 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host) { json_t* mon_rel = mxs_json_relationship(host, MXS_JSON_API_SERVERS); - for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) { mxs_json_add_relation(mon_rel, db->server->unique_name, CN_SERVERS); } @@ -1812,7 +1812,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host) if (mon->active) { - for (MXS_MONITOR_SERVERS* db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = mon->databases; db; db = db->next) { if (db->server == server) { @@ -1900,7 +1900,7 @@ static FILE* open_tmp_file(MXS_MONITOR *monitor, char *path) * PATH_MAX bytes long * @param size Size of @c data */ -static void store_data(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master, uint8_t *data, uint32_t size) +static void store_data(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master, uint8_t *data, uint32_t size) { uint8_t* ptr = data; @@ -1912,7 +1912,7 @@ static void store_data(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master, uint8_ *ptr++ = MMB_SCHEMA_VERSION; /** Store the states of all servers */ - for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) { *ptr++ = (char)SVT_SERVER; // Value type memcpy(ptr, db->server->unique_name, strlen(db->server->unique_name)); // Name of the server @@ -1998,7 +1998,7 @@ static bool has_null_terminator(const char *data, const char *end) */ static const char* process_server(MXS_MONITOR *monitor, const char *data, const char *end) { - for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) { if (strcmp(db->server->unique_name, data) == 0) { @@ -2023,12 +2023,12 @@ static const char* process_server(MXS_MONITOR *monitor, const char *data, const /** * Process a master */ -static const char* process_master(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master, const char *data, +static const char* process_master(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master, const char *data, const char *end) { if (master) { - for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) { if (strcmp(db->server->unique_name, data) == 0) { @@ -2057,7 +2057,7 @@ static bool check_crc32(const uint8_t *data, uint32_t size, const uint8_t *crc_p /** * Process the stored journal data */ -static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master, const char *data, +static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master, const char *data, const char *crc_ptr) { const char *ptr = data; @@ -2097,12 +2097,12 @@ static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master return true; } -void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master) +void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master) { /** Calculate how much memory we need to allocate */ uint32_t size = MMB_LEN_SCHEMA_VERSION + MMB_LEN_CRC32; - for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) { /** Each server is stored as a type byte and a null-terminated string * followed by eight byte server status. */ @@ -2148,7 +2148,7 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master) MXS_FREE(data); } -void load_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master) +void load_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master) { char path[PATH_MAX]; FILE *file = open_data_file(monitor, path); diff --git a/server/modules/monitor/auroramon/auroramon.c b/server/modules/monitor/auroramon/auroramon.c index cf15d6ad1..ed9d465ed 100644 --- a/server/modules/monitor/auroramon/auroramon.c +++ b/server/modules/monitor/auroramon/auroramon.c @@ -43,7 +43,7 @@ typedef struct aurora_monitor * @param monitor Monitor object * @param database Server whose status should be updated */ -void update_server_status(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *database) +void update_server_status(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *database) { if (!SERVER_IN_MAINT(database->server)) { @@ -125,7 +125,7 @@ monitorMain(void *arg) lock_monitor_servers(monitor); servers_status_pending_to_current(monitor); - for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) { update_server_status(monitor, ptr); diff --git a/server/modules/monitor/galeramon/galeramon.c b/server/modules/monitor/galeramon/galeramon.c index 307d03dcb..5c522b7f4 100644 --- a/server/modules/monitor/galeramon/galeramon.c +++ b/server/modules/monitor/galeramon/galeramon.c @@ -34,8 +34,8 @@ static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *params); static void stopMonitor(MXS_MONITOR *); static void diagnostics(DCB *, const MXS_MONITOR *); static json_t* diagnostics_json(const MXS_MONITOR *); -static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR*); -static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *, MXS_MONITOR_SERVERS *, int); +static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR*); +static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *, MXS_MONITORED_SERVER *, int); static void disableMasterFailback(void *, int); bool isGaleraEvent(mxs_monitor_event_t event); static void update_sst_donor_nodes(MXS_MONITOR*, int); @@ -269,7 +269,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) * @param database The database to probe */ static void -monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database) +monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database) { GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle; MYSQL_ROW row; @@ -483,9 +483,9 @@ monitorMain(void *arg) { GALERA_MONITOR *handle = (GALERA_MONITOR*)arg; MXS_MONITOR* mon = handle->monitor; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; size_t nrounds = 0; - MXS_MONITOR_SERVERS *candidate_master = NULL; + MXS_MONITORED_SERVER *candidate_master = NULL; int master_stickiness; int is_cluster = 0; int log_no_members = 1; @@ -666,10 +666,10 @@ monitorMain(void *arg) * @param servers The monitored servers list * @return The candidate master on success, NULL on failure */ -static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR* mon) +static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon) { - MXS_MONITOR_SERVERS *moitor_servers = mon->databases; - MXS_MONITOR_SERVERS *candidate_master = NULL; + MXS_MONITORED_SERVER *moitor_servers = mon->databases; + MXS_MONITORED_SERVER *candidate_master = NULL; GALERA_MONITOR* handle = mon->handle; long min_id = -1; int minval = INT_MAX; @@ -741,8 +741,8 @@ static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR* mon) * @param candidate_master The candidate master server accordingly to the selection rule * @return The master node pointer (could be NULL) */ -static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_master, - MXS_MONITOR_SERVERS *candidate_master, +static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *current_master, + MXS_MONITORED_SERVER *candidate_master, int master_stickiness) { /* @@ -791,7 +791,7 @@ static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_mast */ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) { - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; MYSQL_ROW row; MYSQL_RES *result; GALERA_MONITOR *handle = mon->handle; @@ -804,7 +804,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) } unsigned int found_slaves = 0; - MXS_MONITOR_SERVERS *node_list[is_cluster - 1]; + MXS_MONITORED_SERVER *node_list[is_cluster - 1]; /* Donor list size = DONOR_LIST_SET_VAR + n_hosts * max_host_len + n_hosts + 1 */ char *donor_list = MXS_CALLOC(1, strlen(DONOR_LIST_SET_VAR) + @@ -826,7 +826,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) { if (SERVER_IS_JOINED(ptr->server) && SERVER_IS_SLAVE(ptr->server)) { - node_list[found_slaves] = (MXS_MONITOR_SERVERS *)ptr; + node_list[found_slaves] = (MXS_MONITORED_SERVER *)ptr; found_slaves++; /* Check the server parameter "priority" @@ -854,13 +854,13 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) /* Sort the array */ qsort(node_list, found_slaves, - sizeof(MXS_MONITOR_SERVERS *), + sizeof(MXS_MONITORED_SERVER *), sort_order ? compare_node_priority : compare_node_index); /* Select nodename from each server and append it to node_list */ for (int k = 0; k < found_slaves; k++) { - MXS_MONITOR_SERVERS *ptr = node_list[k]; + MXS_MONITORED_SERVER *ptr = node_list[k]; /* Get the Galera node name */ if (mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0 @@ -906,7 +906,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) /* Set now rep_sst_donor in each slave node */ for (int k = 0; k < found_slaves; k++) { - MXS_MONITOR_SERVERS *ptr = node_list[k]; + MXS_MONITORED_SERVER *ptr = node_list[k]; /* Set the Galera SST donor node list */ if (mysql_query(ptr->con, donor_list) == 0) { @@ -937,8 +937,8 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) static int compare_node_index (const void *a, const void *b) { - const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a; - const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b; + const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a; + const MXS_MONITORED_SERVER *s_b = *(MXS_MONITORED_SERVER * const *)b; // Order is DESC: b - a return s_b->server->node_id - s_a->server->node_id; @@ -965,8 +965,8 @@ static int compare_node_index (const void *a, const void *b) static int compare_node_priority (const void *a, const void *b) { - const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a; - const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b; + const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a; + const MXS_MONITORED_SERVER *s_b = *(MXS_MONITORED_SERVER * const *)b; const char *pri_a = server_get_parameter(s_a->server, "priority"); const char *pri_b = server_get_parameter(s_b->server, "priority"); @@ -1195,7 +1195,7 @@ static void set_cluster_members(MXS_MONITOR *mon) { GALERA_MONITOR *handle = mon->handle; GALERA_NODE_INFO *value; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; char *c_uuid = handle->cluster_info.c_uuid; int c_size = handle->cluster_info.c_size; diff --git a/server/modules/monitor/galeramon/galeramon.h b/server/modules/monitor/galeramon/galeramon.h index 924289035..b5ea9d7a4 100644 --- a/server/modules/monitor/galeramon/galeramon.h +++ b/server/modules/monitor/galeramon/galeramon.h @@ -85,7 +85,7 @@ typedef struct int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */ int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */ bool disableMasterRoleSetting; /**< Monitor flag to disable setting master role */ - MXS_MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */ + MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */ char* script; bool root_node_as_master; /**< Whether we require that the Master should * have a wsrep_local_index of 0 */ diff --git a/server/modules/monitor/grmon/grmon.cc b/server/modules/monitor/grmon/grmon.cc index 6829e81b6..03cb3df05 100644 --- a/server/modules/monitor/grmon/grmon.cc +++ b/server/modules/monitor/grmon/grmon.cc @@ -40,12 +40,12 @@ public: ~GRMon(); private: - THREAD m_thread; /**< Monitor thread */ - int m_shutdown; /**< Flag to shutdown the monitor thread */ - MXS_MONITOR_SERVERS* m_master; /**< The master server */ - std::string m_script; - uint64_t m_events; /**< Enabled events */ - MXS_MONITOR* m_monitor; + THREAD m_thread; /**< Monitor thread */ + int m_shutdown; /**< Flag to shutdown the monitor thread */ + MXS_MONITORED_SERVER* m_master; /**< The master server */ + std::string m_script; + uint64_t m_events; /**< Enabled events */ + MXS_MONITOR* m_monitor; GRMon(MXS_MONITOR* monitor, const MXS_CONFIG_PARAMETER *params); @@ -148,7 +148,7 @@ static inline bool is_false(const char* value) strcasecmp(value, "false") == 0; } -static bool is_master(MXS_MONITOR_SERVERS* server) +static bool is_master(MXS_MONITORED_SERVER* server) { bool rval = false; MYSQL_RES* result; @@ -175,7 +175,7 @@ static bool is_master(MXS_MONITOR_SERVERS* server) return rval; } -static bool is_slave(MXS_MONITOR_SERVERS* server) +static bool is_slave(MXS_MONITORED_SERVER* server) { bool rval = false; MYSQL_RES* result; @@ -202,7 +202,7 @@ static bool is_slave(MXS_MONITOR_SERVERS* server) return rval; } -static void update_server_status(MXS_MONITOR* monitor, MXS_MONITOR_SERVERS* server) +static void update_server_status(MXS_MONITOR* monitor, MXS_MONITORED_SERVER* server) { /* Don't even probe server flagged as in maintenance */ if (SERVER_IN_MAINT(server->server)) @@ -273,7 +273,7 @@ void GRMon::main() lock_monitor_servers(m_monitor); servers_status_pending_to_current(m_monitor); - for (MXS_MONITOR_SERVERS *ptr = m_monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = m_monitor->databases; ptr; ptr = ptr->next) { update_server_status(m_monitor, ptr); } @@ -362,4 +362,4 @@ extern "C" return &info; } -} \ No newline at end of file +} diff --git a/server/modules/monitor/mmmon/mmmon.c b/server/modules/monitor/mmmon/mmmon.c index 568cc5da0..71ce5d498 100644 --- a/server/modules/monitor/mmmon/mmmon.c +++ b/server/modules/monitor/mmmon/mmmon.c @@ -43,7 +43,7 @@ static void stopMonitor(MXS_MONITOR *); static void diagnostics(DCB *, const MXS_MONITOR *); static json_t* diagnostics_json(const MXS_MONITOR *); static void detectStaleMaster(void *, int); -static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *); +static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *); static bool isMySQLEvent(mxs_monitor_event_t event); /** @@ -203,7 +203,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) * @param database The database to probe */ static void -monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database) +monitorDatabase(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database) { MYSQL_ROW row; MYSQL_RES *result; @@ -500,9 +500,9 @@ monitorMain(void *arg) { MM_MONITOR *handle = (MM_MONITOR *)arg; MXS_MONITOR* mon = handle->monitor; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; int detect_stale_master = false; - MXS_MONITOR_SERVERS *root_master = NULL; + MXS_MONITORED_SERVER *root_master = NULL; size_t nrounds = 0; detect_stale_master = handle->detectStaleMaster; @@ -651,10 +651,10 @@ detectStaleMaster(void *arg, int enable) * @return The server at root level with SERVER_MASTER bit */ -static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *mon) +static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon) { MM_MONITOR* handle = mon->handle; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; ptr = mon->databases; diff --git a/server/modules/monitor/mmmon/mmmon.h b/server/modules/monitor/mmmon/mmmon.h index cbf434e1f..679e9dc2b 100644 --- a/server/modules/monitor/mmmon/mmmon.h +++ b/server/modules/monitor/mmmon/mmmon.h @@ -45,7 +45,7 @@ typedef struct int status; /**< Monitor status */ unsigned long id; /**< Monitor ID */ int detectStaleMaster; /**< Monitor flag for Stale Master detection */ - MXS_MONITOR_SERVERS *master; /**< Master server for Master/Slave replication */ + MXS_MONITORED_SERVER *master; /**< Master server for Master/Slave replication */ char* script; /*< Script to call when state changes occur on servers */ uint64_t events; /*< enabled events */ MXS_MONITOR* monitor; diff --git a/server/modules/monitor/mysqlmon.h b/server/modules/monitor/mysqlmon.h index 8e8e8a723..cf0b3f074 100644 --- a/server/modules/monitor/mysqlmon.h +++ b/server/modules/monitor/mysqlmon.h @@ -69,7 +69,7 @@ typedef struct int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */ int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */ bool mysql51_replication; /**< Use MySQL 5.1 replication */ - MXS_MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */ + MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */ char* script; /*< Script to call when state changes occur on servers */ uint64_t events; /*< enabled events */ HASHTABLE *server_info; /**< Contains server specific information */ diff --git a/server/modules/monitor/mysqlmon/mysql_mon.cc b/server/modules/monitor/mysqlmon/mysql_mon.cc index bc9c742e1..fc9ced7d6 100644 --- a/server/modules/monitor/mysqlmon/mysql_mon.cc +++ b/server/modules/monitor/mysqlmon/mysql_mon.cc @@ -49,11 +49,11 @@ static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER*); static void stopMonitor(MXS_MONITOR *); static void diagnostics(DCB *, const MXS_MONITOR *); static json_t* diagnostics_json(const MXS_MONITOR *); -static MXS_MONITOR_SERVERS *getServerByNodeId(MXS_MONITOR_SERVERS *, long); -static MXS_MONITOR_SERVERS *getSlaveOfNodeId(MXS_MONITOR_SERVERS *, long); -static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *, int); -static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITOR_SERVERS *); -static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITOR_SERVERS *); +static MXS_MONITORED_SERVER *getServerByNodeId(MXS_MONITORED_SERVER *, long); +static MXS_MONITORED_SERVER *getSlaveOfNodeId(MXS_MONITORED_SERVER *, long); +static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *, int); +static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITORED_SERVER *); +static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITORED_SERVER *); static int add_slave_to_master(long *, int, long); static bool isMySQLEvent(mxs_monitor_event_t event); void check_maxscale_schema_replication(MXS_MONITOR *monitor); @@ -186,7 +186,7 @@ void info_free_func(void *val) * @return True on success, false if initialization failed. At the moment * initialization can only fail if memory allocation fails. */ -bool init_server_info(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database) +bool init_server_info(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database) { bool rval = true; @@ -328,7 +328,7 @@ static void diagnostics(DCB *dcb, const MXS_MONITOR *mon) dcb_printf(dcb, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled"); dcb_printf(dcb, "Server information\n\n"); - for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next) { MYSQL_SERVER_INFO *serv_info = static_cast(hashtable_fetch(handle->server_info, db->server->unique_name)); @@ -380,7 +380,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) { json_t* arr = json_array(); - for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next) { json_t* srv = json_object(); MYSQL_SERVER_INFO *serv_info = @@ -419,7 +419,7 @@ enum mysql_server_version MYSQL_SERVER_VERSION_51 }; -static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_INFO *serv_info, +static inline void monitor_mysql_db(MXS_MONITORED_SERVER* database, MYSQL_SERVER_INFO *serv_info, enum mysql_server_version server_version) { unsigned int columns; @@ -554,10 +554,10 @@ static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_ * @param mon Monitor * @return Lowest server ID master in the monitor */ -static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon) +static MXS_MONITORED_SERVER *build_mysql51_replication_tree(MXS_MONITOR *mon) { - MXS_MONITOR_SERVERS* database = mon->databases; - MXS_MONITOR_SERVERS *ptr, *rval = NULL; + MXS_MONITORED_SERVER* database = mon->databases; + MXS_MONITORED_SERVER *ptr, *rval = NULL; int i; MYSQL_MONITOR *handle = static_cast(mon->handle); @@ -669,7 +669,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon) * @param database The database to probe */ static void -monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database) +monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database) { MYSQL_MONITOR* handle = static_cast(mon->handle); MYSQL_ROW row; @@ -830,7 +830,7 @@ struct graph_node bool active; struct graph_node *parent; MYSQL_SERVER_INFO *info; - MXS_MONITOR_SERVERS *db; + MXS_MONITORED_SERVER *db; }; /** @@ -943,13 +943,13 @@ static void visit_node(struct graph_node *node, struct graph_node **stack, * member. Nodes in a group get a positive group ID where the nodes not in a * group get a group ID of 0. */ -void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database, int nservers) +void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database, int nservers) { struct graph_node graph[nservers]; struct graph_node *stack[nservers]; int nodes = 0; - for (MXS_MONITOR_SERVERS *db = database; db; db = db->next) + for (MXS_MONITORED_SERVER *db = database; db; db = db->next) { graph[nodes].info = static_cast(hashtable_fetch(handle->server_info, db->server->unique_name)); @@ -1051,7 +1051,7 @@ void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database, int * * @return True if failover is required */ -bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db) +bool failover_required(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *db) { int candidates = 0; @@ -1091,7 +1091,7 @@ bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db) * @param handle Monitor instance * @param db Monitor servers */ -void do_failover(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db) +void do_failover(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *db) { while (db) { @@ -1130,11 +1130,11 @@ monitorMain(void *arg) { MYSQL_MONITOR *handle = (MYSQL_MONITOR *) arg; MXS_MONITOR* mon = handle->monitor; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; int replication_heartbeat; bool detect_stale_master; int num_servers = 0; - MXS_MONITOR_SERVERS *root_master = NULL; + MXS_MONITORED_SERVER *root_master = NULL; size_t nrounds = 0; int log_no_master = 1; bool heartbeat_checked = false; @@ -1494,8 +1494,8 @@ monitorMain(void *arg) * @param node_id The MySQL server_id to fetch * @return The server with the required server_id */ -static MXS_MONITOR_SERVERS * -getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id) +static MXS_MONITORED_SERVER * +getServerByNodeId(MXS_MONITORED_SERVER *ptr, long node_id) { SERVER *current; while (ptr) @@ -1517,8 +1517,8 @@ getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id) * @param node_id The MySQL server_id to fetch * @return The slave server of this node_id */ -static MXS_MONITOR_SERVERS * -getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id) +static MXS_MONITORED_SERVER * +getSlaveOfNodeId(MXS_MONITORED_SERVER *ptr, long node_id) { SERVER *current; while (ptr) @@ -1541,7 +1541,7 @@ getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id) * @param handle The monitor handle * @param database The number database server */ -static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database) +static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database) { unsigned long id = handle->id; time_t heartbeat; @@ -1675,7 +1675,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat * @param handle The monitor handle * @param database The number database server */ -static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database) +static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database) { MYSQL_MONITOR *handle = (MYSQL_MONITOR*) mon->handle; unsigned long id = handle->id; @@ -1786,11 +1786,11 @@ static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database) * @return The server at root level with SERVER_MASTER bit */ -static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_servers) +static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_servers) { MYSQL_MONITOR* handle = (MYSQL_MONITOR*) mon->handle; - MXS_MONITOR_SERVERS *ptr; - MXS_MONITOR_SERVERS *backend; + MXS_MONITORED_SERVER *ptr; + MXS_MONITORED_SERVER *backend; SERVER *current; int depth = 0; long node_id; @@ -1816,7 +1816,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve node_id = current->master_id; if (node_id < 1) { - MXS_MONITOR_SERVERS *find_slave; + MXS_MONITORED_SERVER *find_slave; find_slave = getSlaveOfNodeId(mon->databases, current->node_id); if (find_slave == NULL) @@ -1863,7 +1863,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve } else { - MXS_MONITOR_SERVERS *master; + MXS_MONITORED_SERVER *master; current->depth = depth; master = getServerByNodeId(mon->databases, current->master_id); @@ -1967,7 +1967,7 @@ static int add_slave_to_master(long *slaves_list, int list_size, long node_id) * @return False if the table is not replicated or an error occurred when querying * the server */ -bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database) +bool check_replicate_ignore_table(MXS_MONITORED_SERVER* database) { MYSQL_RES *result; bool rval = true; @@ -2011,7 +2011,7 @@ bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database) * @return False if the table is not replicated or an error occurred when querying * the server */ -bool check_replicate_do_table(MXS_MONITOR_SERVERS* database) +bool check_replicate_do_table(MXS_MONITORED_SERVER* database) { MYSQL_RES *result; bool rval = true; @@ -2054,7 +2054,7 @@ bool check_replicate_do_table(MXS_MONITOR_SERVERS* database) * @return False if the table is not replicated or an error occurred when trying to * query the server. */ -bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database) +bool check_replicate_wild_do_table(MXS_MONITORED_SERVER* database) { MYSQL_RES *result; bool rval = true; @@ -2101,7 +2101,7 @@ bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database) * @return False if the table is not replicated or an error occurred when trying to * query the server. */ -bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database) +bool check_replicate_wild_ignore_table(MXS_MONITORED_SERVER* database) { MYSQL_RES *result; bool rval = true; @@ -2148,7 +2148,7 @@ bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database) */ void check_maxscale_schema_replication(MXS_MONITOR *monitor) { - MXS_MONITOR_SERVERS* database = monitor->databases; + MXS_MONITORED_SERVER* database = monitor->databases; bool err = false; while (database) diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.c b/server/modules/monitor/ndbclustermon/ndbclustermon.c index 520569f9e..398d9ccba 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.c +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.c @@ -188,7 +188,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) * @param database The database to probe */ static void -monitorDatabase(MXS_MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MXS_MONITOR *mon) +monitorDatabase(MXS_MONITORED_SERVER *database, char *defaultUser, char *defaultPasswd, MXS_MONITOR *mon) { MYSQL_ROW row; MYSQL_RES *result; @@ -308,7 +308,7 @@ monitorMain(void *arg) { MYSQL_MONITOR *handle = (MYSQL_MONITOR*)arg; MXS_MONITOR* mon = handle->monitor; - MXS_MONITOR_SERVERS *ptr; + MXS_MONITORED_SERVER *ptr; size_t nrounds = 0; if (mysql_thread_init()) From 68432bbaa3c38e5c7cff6cf2a88720610a362f6d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 2 Oct 2017 15:31:54 +0300 Subject: [PATCH 7/7] Rename MXS_MONITOR::databases to MXS_MONITOR::monitored_servers More descriptive name. Some local varaibles could now also be renamed to be more descriptive, but that's for another day. --- include/maxscale/monitor.h | 2 +- server/core/config_runtime.cc | 4 +- server/core/monitor.cc | 70 +++++++++---------- server/modules/monitor/auroramon/auroramon.c | 2 +- server/modules/monitor/galeramon/galeramon.c | 10 +-- server/modules/monitor/grmon/grmon.cc | 2 +- server/modules/monitor/mmmon/mmmon.c | 6 +- server/modules/monitor/mysqlmon/mysql_mon.cc | 44 ++++++------ .../monitor/ndbclustermon/ndbclustermon.c | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/include/maxscale/monitor.h b/include/maxscale/monitor.h index 5a75a9fd6..25e657400 100644 --- a/include/maxscale/monitor.h +++ b/include/maxscale/monitor.h @@ -182,7 +182,7 @@ struct mxs_monitor char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */ SPINLOCK lock; MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */ - MXS_MONITORED_SERVER* databases; /*< List of databases the monitor monitors */ + MXS_MONITORED_SERVER* monitored_servers; /*< List of servers the monitor monitors */ monitor_state_t state; /**< The state of the monitor */ int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */ int connect_attempts; /**< How many times a connection is attempted */ diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 7f949f9dd..19fa59fdb 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -960,9 +960,9 @@ bool runtime_destroy_monitor(MXS_MONITOR *monitor) { monitorStop(monitor); - while (monitor->databases) + while (monitor->monitored_servers) { - monitorRemoveServer(monitor, monitor->databases->server); + monitorRemoveServer(monitor, monitor->monitored_servers->server); } monitorDestroy(monitor); MXS_NOTICE("Destroyed monitor '%s'", monitor->name); diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 5f549950a..c5994d861 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -123,7 +123,7 @@ MXS_MONITOR* monitor_alloc(const char *name, const char *module) mon->name = my_name; mon->module_name = my_module; mon->handle = NULL; - mon->databases = NULL; + mon->monitored_servers = NULL; *mon->password = '\0'; *mon->user = '\0'; mon->read_timeout = DEFAULT_READ_TIMEOUT; @@ -176,7 +176,7 @@ monitor_free(MXS_MONITOR *mon) } spinlock_release(&monLock); config_parameter_free(mon->parameters); - monitor_server_free_all(mon->databases); + monitor_server_free_all(mon->monitored_servers); MXS_FREE(mon->name); MXS_FREE(mon->module_name); MXS_FREE(mon); @@ -253,7 +253,7 @@ monitorStop(MXS_MONITOR *monitor) monitor->module->stopMonitor(monitor); monitor->state = MONITOR_STATE_STOPPED; - MXS_MONITORED_SERVER* db = monitor->databases; + MXS_MONITORED_SERVER* db = monitor->monitored_servers; while (db) { // TODO: Create a generic entry point for this or move it inside stopMonitor @@ -335,13 +335,13 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server) spinlock_acquire(&mon->lock); - if (mon->databases == NULL) + if (mon->monitored_servers == NULL) { - mon->databases = db; + mon->monitored_servers = db; } else { - MXS_MONITORED_SERVER *ptr = mon->databases; + MXS_MONITORED_SERVER *ptr = mon->monitored_servers; while (ptr->next != NULL) { ptr = ptr->next; @@ -402,11 +402,11 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server) spinlock_acquire(&mon->lock); - MXS_MONITORED_SERVER *ptr = mon->databases; + MXS_MONITORED_SERVER *ptr = mon->monitored_servers; if (ptr && ptr->server == server) { - mon->databases = mon->databases->next; + mon->monitored_servers = mon->monitored_servers->next; } else { @@ -522,7 +522,7 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor) const char *sep = ""; - for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->monitored_servers; db; db = db->next) { dcb_printf(dcb, "%s[%s]:%d", sep, db->server->name, db->server->port); sep = ", "; @@ -782,7 +782,7 @@ monitorGetList() */ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query) { - if (monitor->databases == NULL || // No servers to check + if (monitor->monitored_servers == NULL || // No servers to check config_get_global_options()->skip_permission_checks) { return true; @@ -793,7 +793,7 @@ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query) MXS_CONFIG* cnf = config_get_global_options(); bool rval = false; - for (MXS_MONITORED_SERVER *mondb = monitor->databases; mondb; mondb = mondb->next) + for (MXS_MONITORED_SERVER *mondb = monitor->monitored_servers; mondb; mondb = mondb->next) { if (mon_ping_or_connect_to_db(monitor, mondb) != MONITOR_CONN_OK) { @@ -1223,7 +1223,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITORED_SERVER* ptr, const char* s if (externcmd_matches(cmd, "$PARENT")) { std::stringstream ss; - MXS_MONITORED_SERVER* parent = find_parent_node(mon->databases, ptr); + MXS_MONITORED_SERVER* parent = find_parent_node(mon->monitored_servers, ptr); if (parent) { @@ -1234,7 +1234,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITORED_SERVER* ptr, const char* s if (externcmd_matches(cmd, "$CHILDREN")) { - externcmd_substitute_arg(cmd, "[$]CHILDREN", child_nodes(mon->databases, ptr).c_str()); + externcmd_substitute_arg(cmd, "[$]CHILDREN", child_nodes(mon->monitored_servers, ptr).c_str()); } if (externcmd_matches(cmd, "$EVENT")) @@ -1246,31 +1246,31 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITORED_SERVER* ptr, const char* s if (externcmd_matches(cmd, "$NODELIST")) { - mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_RUNNING); + mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_RUNNING); externcmd_substitute_arg(cmd, "[$]NODELIST", nodelist); } if (externcmd_matches(cmd, "$LIST")) { - mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), 0); + mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), 0); externcmd_substitute_arg(cmd, "[$]LIST", nodelist); } if (externcmd_matches(cmd, "$MASTERLIST")) { - mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_MASTER); + mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_MASTER); externcmd_substitute_arg(cmd, "[$]MASTERLIST", nodelist); } if (externcmd_matches(cmd, "$SLAVELIST")) { - mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_SLAVE); + mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_SLAVE); externcmd_substitute_arg(cmd, "[$]SLAVELIST", nodelist); } if (externcmd_matches(cmd, "$SYNCEDLIST")) { - mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_JOINED); + mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_JOINED); externcmd_substitute_arg(cmd, "[$]SYNCEDLIST", nodelist); } @@ -1451,7 +1451,7 @@ MXS_MONITOR* monitor_server_in_use(const SERVER *server) if (mon->active) { - for (MXS_MONITORED_SERVER *db = mon->databases; db && !rval; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db && !rval; db = db->next) { if (db->server == server) { @@ -1492,12 +1492,12 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena dprintf(file, "%s=%ld\n", CN_JOURNAL_MAX_AGE, monitor->journal_max_age); dprintf(file, "%s=%d\n", CN_SCRIPT_TIMEOUT, monitor->script_timeout); - if (monitor->databases) + if (monitor->monitored_servers) { dprintf(file, "%s=", CN_SERVERS); - for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->monitored_servers; db; db = db->next) { - if (db != monitor->databases) + if (db != monitor->monitored_servers) { dprintf(file, ","); } @@ -1575,7 +1575,7 @@ bool monitor_serialize(const MXS_MONITOR *monitor) void mon_hangup_failed_servers(MXS_MONITOR *monitor) { - for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; ptr; ptr = ptr->next) { if (mon_status_changed(ptr) && (!(SERVER_IS_RUNNING(ptr->server)) || @@ -1600,7 +1600,7 @@ void mon_report_query_error(MXS_MONITORED_SERVER* db) */ void lock_monitor_servers(MXS_MONITOR *monitor) { - MXS_MONITORED_SERVER *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; while (ptr) { spinlock_acquire(&ptr->server->lock); @@ -1614,7 +1614,7 @@ void lock_monitor_servers(MXS_MONITOR *monitor) */ void release_monitor_servers(MXS_MONITOR *monitor) { - MXS_MONITORED_SERVER *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; while (ptr) { spinlock_release(&ptr->server->lock); @@ -1629,7 +1629,7 @@ void release_monitor_servers(MXS_MONITOR *monitor) */ void servers_status_pending_to_current(MXS_MONITOR *monitor) { - MXS_MONITORED_SERVER *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; while (ptr) { ptr->server->status = ptr->server->status_pending; @@ -1645,7 +1645,7 @@ void servers_status_pending_to_current(MXS_MONITOR *monitor) */ void servers_status_current_to_pending(MXS_MONITOR *monitor) { - MXS_MONITORED_SERVER *ptr = monitor->databases; + MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; while (ptr) { ptr->server->status_pending = ptr->server->status; @@ -1655,7 +1655,7 @@ void servers_status_current_to_pending(MXS_MONITOR *monitor) void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events) { - for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; ptr; ptr = ptr->next) { if (mon_status_changed(ptr)) { @@ -1748,11 +1748,11 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host) json_t* rel = json_object(); - if (monitor->databases) + if (monitor->monitored_servers) { json_t* mon_rel = mxs_json_relationship(host, MXS_JSON_API_SERVERS); - for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = monitor->monitored_servers; db; db = db->next) { mxs_json_add_relation(mon_rel, db->server->unique_name, CN_SERVERS); } @@ -1812,7 +1812,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host) if (mon->active) { - for (MXS_MONITORED_SERVER* db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = mon->monitored_servers; db; db = db->next) { if (db->server == server) { @@ -1912,7 +1912,7 @@ static void store_data(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master, uint8 *ptr++ = MMB_SCHEMA_VERSION; /** Store the states of all servers */ - for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next) { *ptr++ = (char)SVT_SERVER; // Value type memcpy(ptr, db->server->unique_name, strlen(db->server->unique_name)); // Name of the server @@ -1998,7 +1998,7 @@ static bool has_null_terminator(const char *data, const char *end) */ static const char* process_server(MXS_MONITOR *monitor, const char *data, const char *end) { - for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next) { if (strcmp(db->server->unique_name, data) == 0) { @@ -2028,7 +2028,7 @@ static const char* process_master(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **m { if (master) { - for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next) { if (strcmp(db->server->unique_name, data) == 0) { @@ -2102,7 +2102,7 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master) /** Calculate how much memory we need to allocate */ uint32_t size = MMB_LEN_SCHEMA_VERSION + MMB_LEN_CRC32; - for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next) + for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next) { /** Each server is stored as a type byte and a null-terminated string * followed by eight byte server status. */ diff --git a/server/modules/monitor/auroramon/auroramon.c b/server/modules/monitor/auroramon/auroramon.c index ed9d465ed..1ea9b850f 100644 --- a/server/modules/monitor/auroramon/auroramon.c +++ b/server/modules/monitor/auroramon/auroramon.c @@ -125,7 +125,7 @@ monitorMain(void *arg) lock_monitor_servers(monitor); servers_status_pending_to_current(monitor); - for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; ptr; ptr = ptr->next) { update_server_status(monitor, ptr); diff --git a/server/modules/monitor/galeramon/galeramon.c b/server/modules/monitor/galeramon/galeramon.c index 5c522b7f4..cfb134373 100644 --- a/server/modules/monitor/galeramon/galeramon.c +++ b/server/modules/monitor/galeramon/galeramon.c @@ -534,7 +534,7 @@ monitorMain(void *arg) lock_monitor_servers(mon); servers_status_pending_to_current(mon); - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { ptr->mon_prev_status = ptr->server->status; @@ -583,7 +583,7 @@ monitorMain(void *arg) handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness); - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { @@ -668,7 +668,7 @@ monitorMain(void *arg) */ static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon) { - MXS_MONITORED_SERVER *moitor_servers = mon->databases; + MXS_MONITORED_SERVER *moitor_servers = mon->monitored_servers; MXS_MONITORED_SERVER *candidate_master = NULL; GALERA_MONITOR* handle = mon->handle; long min_id = -1; @@ -819,7 +819,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) strcpy(donor_list, DONOR_LIST_SET_VAR); - ptr = mon->databases; + ptr = mon->monitored_servers; /* Create an array of slave nodes */ while (ptr) @@ -1199,7 +1199,7 @@ static void set_cluster_members(MXS_MONITOR *mon) char *c_uuid = handle->cluster_info.c_uuid; int c_size = handle->cluster_info.c_size; - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { /* Fetch cluster info for this server, if any */ diff --git a/server/modules/monitor/grmon/grmon.cc b/server/modules/monitor/grmon/grmon.cc index 03cb3df05..78d0a38f4 100644 --- a/server/modules/monitor/grmon/grmon.cc +++ b/server/modules/monitor/grmon/grmon.cc @@ -273,7 +273,7 @@ void GRMon::main() lock_monitor_servers(m_monitor); servers_status_pending_to_current(m_monitor); - for (MXS_MONITORED_SERVER *ptr = m_monitor->databases; ptr; ptr = ptr->next) + for (MXS_MONITORED_SERVER *ptr = m_monitor->monitored_servers; ptr; ptr = ptr->next) { update_server_status(m_monitor, ptr); } diff --git a/server/modules/monitor/mmmon/mmmon.c b/server/modules/monitor/mmmon/mmmon.c index 71ce5d498..30ebd0947 100644 --- a/server/modules/monitor/mmmon/mmmon.c +++ b/server/modules/monitor/mmmon/mmmon.c @@ -547,7 +547,7 @@ monitorMain(void *arg) servers_status_pending_to_current(mon); /* start from the first server in the list */ - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { @@ -584,7 +584,7 @@ monitorMain(void *arg) /* Update server status from monitor pending status on that server*/ - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { if (!SERVER_IN_MAINT(ptr->server)) @@ -656,7 +656,7 @@ static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon) MM_MONITOR* handle = mon->handle; MXS_MONITORED_SERVER *ptr; - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { diff --git a/server/modules/monitor/mysqlmon/mysql_mon.cc b/server/modules/monitor/mysqlmon/mysql_mon.cc index fc9ced7d6..8efa52f9f 100644 --- a/server/modules/monitor/mysqlmon/mysql_mon.cc +++ b/server/modules/monitor/mysqlmon/mysql_mon.cc @@ -275,7 +275,7 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params) error = true; } - if (!init_server_info(handle, monitor->databases)) + if (!init_server_info(handle, monitor->monitored_servers)) { error = true; } @@ -328,7 +328,7 @@ static void diagnostics(DCB *dcb, const MXS_MONITOR *mon) dcb_printf(dcb, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled"); dcb_printf(dcb, "Server information\n\n"); - for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db; db = db->next) { MYSQL_SERVER_INFO *serv_info = static_cast(hashtable_fetch(handle->server_info, db->server->unique_name)); @@ -376,11 +376,11 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) json_object_set_new(rval, "script", json_string(handle->script)); } - if (mon->databases) + if (mon->monitored_servers) { json_t* arr = json_array(); - for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next) + for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db; db = db->next) { json_t* srv = json_object(); MYSQL_SERVER_INFO *serv_info = @@ -556,7 +556,7 @@ static inline void monitor_mysql_db(MXS_MONITORED_SERVER* database, MYSQL_SERVER */ static MXS_MONITORED_SERVER *build_mysql51_replication_tree(MXS_MONITOR *mon) { - MXS_MONITORED_SERVER* database = mon->databases; + MXS_MONITORED_SERVER* database = mon->monitored_servers; MXS_MONITORED_SERVER *ptr, *rval = NULL; int i; MYSQL_MONITOR *handle = static_cast(mon->handle); @@ -623,12 +623,12 @@ static MXS_MONITORED_SERVER *build_mysql51_replication_tree(MXS_MONITOR *mon) database = database->next; } - database = mon->databases; + database = mon->monitored_servers; /** Set master server IDs */ while (database) { - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { @@ -1190,7 +1190,7 @@ monitorMain(void *arg) servers_status_pending_to_current(mon); /* start from the first server in the list */ - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { @@ -1247,7 +1247,7 @@ monitorMain(void *arg) ptr = ptr->next; } - ptr = mon->databases; + ptr = mon->monitored_servers; /* if only one server is configured, that's is Master */ if (num_servers == 1) { @@ -1283,10 +1283,10 @@ monitorMain(void *arg) /** Find all the master server cycles in the cluster graph. If multiple masters are found, the servers with the read_only variable set to ON will be assigned the slave status. */ - find_graph_cycles(handle, mon->databases, num_servers); + find_graph_cycles(handle, mon->monitored_servers, num_servers); } - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { MYSQL_SERVER_INFO *serv_info = @@ -1295,8 +1295,8 @@ monitorMain(void *arg) ss_dassert(serv_info); if (ptr->server->node_id > 0 && ptr->server->master_id > 0 && - getSlaveOfNodeId(mon->databases, ptr->server->node_id) && - getServerByNodeId(mon->databases, ptr->server->master_id) && + getSlaveOfNodeId(mon->monitored_servers, ptr->server->node_id) && + getServerByNodeId(mon->monitored_servers, ptr->server->master_id) && (!handle->multimaster || serv_info->group == 0)) { /** This server is both a slave and a master i.e. a relay master */ @@ -1315,7 +1315,7 @@ monitorMain(void *arg) /* Update server status from monitor pending status on that server*/ - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { if (!SERVER_IN_MAINT(ptr->server)) @@ -1401,10 +1401,10 @@ monitorMain(void *arg) if we need to do a failover */ if (handle->detect_standalone_master) { - if (failover_required(handle, mon->databases)) + if (failover_required(handle, mon->monitored_servers)) { /** Other servers have died, initiate a failover to the last remaining server */ - do_failover(handle, mon->databases); + do_failover(handle, mon->monitored_servers); } else { @@ -1457,7 +1457,7 @@ monitorMain(void *arg) SERVER_IS_RELAY_SERVER(root_master->server))) { set_master_heartbeat(handle, root_master); - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { @@ -1796,7 +1796,7 @@ static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_serv long node_id; int root_level; - ptr = mon->databases; + ptr = mon->monitored_servers; root_level = num_servers; while (ptr) @@ -1817,7 +1817,7 @@ static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_serv if (node_id < 1) { MXS_MONITORED_SERVER *find_slave; - find_slave = getSlaveOfNodeId(mon->databases, current->node_id); + find_slave = getSlaveOfNodeId(mon->monitored_servers, current->node_id); if (find_slave == NULL) { @@ -1844,7 +1844,7 @@ static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_serv root_level = current->depth; handle->master = ptr; } - backend = getServerByNodeId(mon->databases, node_id); + backend = getServerByNodeId(mon->monitored_servers, node_id); if (backend) { @@ -1866,7 +1866,7 @@ static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_serv MXS_MONITORED_SERVER *master; current->depth = depth; - master = getServerByNodeId(mon->databases, current->master_id); + master = getServerByNodeId(mon->monitored_servers, current->master_id); if (master && master->server && master->server->node_id > 0) { add_slave_to_master(master->server->slaves, sizeof(master->server->slaves), @@ -2148,7 +2148,7 @@ bool check_replicate_wild_ignore_table(MXS_MONITORED_SERVER* database) */ void check_maxscale_schema_replication(MXS_MONITOR *monitor) { - MXS_MONITORED_SERVER* database = monitor->databases; + MXS_MONITORED_SERVER* database = monitor->monitored_servers; bool err = false; while (database) diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.c b/server/modules/monitor/ndbclustermon/ndbclustermon.c index 398d9ccba..43267bbfa 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.c +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.c @@ -350,7 +350,7 @@ monitorMain(void *arg) lock_monitor_servers(mon); servers_status_pending_to_current(mon); - ptr = mon->databases; + ptr = mon->monitored_servers; while (ptr) { ptr->mon_prev_status = ptr->server->status;