MXS-1703 Run astyle, rewrite comments & reorder fields
No functional changes.
This commit is contained in:
@ -1056,8 +1056,8 @@ void MariaDBMonitor::monitor_one_server(MariaDBServer& server)
|
||||
{
|
||||
/** Master failed, can't recover */
|
||||
MXS_NOTICE("Server [%s]:%d lost the master status.",
|
||||
ptr->server->name,
|
||||
ptr->server->port);
|
||||
ptr->server->name,
|
||||
ptr->server->port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1065,14 +1065,14 @@ void MariaDBMonitor::monitor_one_server(MariaDBServer& server)
|
||||
{
|
||||
#if defined(SS_DEBUG)
|
||||
MXS_INFO("Backend server [%s]:%d state : %s",
|
||||
ptr->server->name,
|
||||
ptr->server->port,
|
||||
STRSRVSTATUS(ptr->server));
|
||||
ptr->server->name,
|
||||
ptr->server->port,
|
||||
STRSRVSTATUS(ptr->server));
|
||||
#else
|
||||
MXS_DEBUG("Backend server [%s]:%d state : %s",
|
||||
ptr->server->name,
|
||||
ptr->server->port,
|
||||
STRSRVSTATUS(ptr->server));
|
||||
ptr->server->name,
|
||||
ptr->server->port,
|
||||
STRSRVSTATUS(ptr->server));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1181,7 +1181,7 @@ void MariaDBMonitor::update_server_states(MariaDBServer& db_server, MariaDBServe
|
||||
*/
|
||||
if (m_detect_stale_master && root_master && !m_detect_multimaster &&
|
||||
(strcmp(ptr->server->name, root_master->server->name) == 0 &&
|
||||
ptr->server->port == root_master->server->port) &&
|
||||
ptr->server->port == root_master->server->port) &&
|
||||
(ptr->server->status & SERVER_MASTER) &&
|
||||
!(ptr->pending_status & SERVER_MASTER) &&
|
||||
!serv_info->read_only)
|
||||
@ -1198,10 +1198,10 @@ void MariaDBMonitor::update_server_states(MariaDBServer& db_server, MariaDBServe
|
||||
if ((ptr->mon_prev_status & SERVER_STALE_STATUS) == 0)
|
||||
{
|
||||
MXS_WARNING("All slave servers under the current master "
|
||||
"server have been lost. Assigning Stale Master"
|
||||
" status to the old master server '%s' (%s:%i).",
|
||||
ptr->server->unique_name, ptr->server->name,
|
||||
ptr->server->port);
|
||||
"server have been lost. Assigning Stale Master"
|
||||
" status to the old master server '%s' (%s:%i).",
|
||||
ptr->server->unique_name, ptr->server->name,
|
||||
ptr->server->port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1227,12 +1227,12 @@ void MariaDBMonitor::update_server_states(MariaDBServer& db_server, MariaDBServe
|
||||
/** If this server was a stale slave candidate, assign
|
||||
* slave status to it */
|
||||
else if (ptr->mon_prev_status & SERVER_STALE_SLAVE &&
|
||||
ptr->pending_status & SERVER_RUNNING &&
|
||||
// Master is down
|
||||
(!root_master || !SERVER_IS_MASTER(root_master->server) ||
|
||||
// Master just came up
|
||||
(SERVER_IS_MASTER(root_master->server) &&
|
||||
(root_master->mon_prev_status & SERVER_MASTER) == 0)))
|
||||
ptr->pending_status & SERVER_RUNNING &&
|
||||
// Master is down
|
||||
(!root_master || !SERVER_IS_MASTER(root_master->server) ||
|
||||
// Master just came up
|
||||
(SERVER_IS_MASTER(root_master->server) &&
|
||||
(root_master->mon_prev_status & SERVER_MASTER) == 0)))
|
||||
{
|
||||
monitor_set_pending_status(ptr, SERVER_SLAVE);
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ bool MariaDBMonitor::do_failover(json_t** err_out)
|
||||
* @return True if relay log was processed within time limit, or false if time ran out or an error occurred.
|
||||
*/
|
||||
bool MariaDBMonitor::failover_wait_relay_log(MXS_MONITORED_SERVER* new_master, int seconds_remaining,
|
||||
json_t** err_out)
|
||||
json_t** err_out)
|
||||
{
|
||||
MariaDBServer* master_info = get_server_info(new_master);
|
||||
time_t begin = time(NULL);
|
||||
@ -1156,7 +1156,7 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerArray* slaves_out, json_t
|
||||
* If multiple slaves have same number of events, select the one with most processed events. */
|
||||
MXS_MONITORED_SERVER* current_best = NULL;
|
||||
MariaDBServer* current_best_info = NULL;
|
||||
// Servers that cannot be selected because of exclusion, but seem otherwise ok.
|
||||
// Servers that cannot be selected because of exclusion, but seem otherwise ok.
|
||||
ServerArray valid_but_excluded;
|
||||
// Index of the current best candidate in slaves_out
|
||||
int master_vector_index = -1;
|
||||
@ -1176,7 +1176,7 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerArray* slaves_out, json_t
|
||||
{
|
||||
valid_but_excluded.push_back(cand);
|
||||
const char CANNOT_SELECT[] = "Promotion candidate '%s' is excluded from new "
|
||||
"master selection.";
|
||||
"master selection.";
|
||||
MXS_INFO(CANNOT_SELECT, cand->name());
|
||||
}
|
||||
else if (cand->check_replication_settings())
|
||||
@ -1210,7 +1210,7 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerArray* slaves_out, json_t
|
||||
if (current_best == NULL)
|
||||
{
|
||||
const char EXCLUDED_ONLY_CAND[] = "Server '%s' is a viable choice for new master, "
|
||||
"but cannot be selected as it's excluded.";
|
||||
"but cannot be selected as it's excluded.";
|
||||
MXS_WARNING(EXCLUDED_ONLY_CAND, excluded_name);
|
||||
break;
|
||||
}
|
||||
@ -1219,8 +1219,8 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerArray* slaves_out, json_t
|
||||
// Print a warning if this server is actually a better candidate than the previous
|
||||
// best.
|
||||
const char EXCLUDED_CAND[] = "Server '%s' is superior to current "
|
||||
"best candidate '%s', but cannot be selected as it's excluded. This may lead to "
|
||||
"loss of data if '%s' is ahead of other servers.";
|
||||
"best candidate '%s', but cannot be selected as it's excluded. This may lead to "
|
||||
"loss of data if '%s' is ahead of other servers.";
|
||||
MXS_WARNING(EXCLUDED_CAND, excluded_name, current_best->server->unique_name, excluded_name);
|
||||
break;
|
||||
}
|
||||
@ -1401,11 +1401,11 @@ bool MariaDBMonitor::failover_check(json_t** error_out)
|
||||
{
|
||||
if (uses_gtid(mon_server, error_out))
|
||||
{
|
||||
slaves++;
|
||||
slaves++;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,8 @@ GtidList GtidList::from_string(const string& gtid_string)
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
} while (have_more && !error);
|
||||
}
|
||||
while (have_more && !error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
@ -96,7 +97,8 @@ bool GtidList::operator == (const GtidList& rhs) const
|
||||
return m_triplets == rhs.m_triplets;
|
||||
}
|
||||
|
||||
uint64_t GtidList::events_ahead(const GtidList& lhs, const GtidList& rhs, substraction_mode_t domain_substraction_mode)
|
||||
uint64_t GtidList::events_ahead(const GtidList& lhs, const GtidList& rhs,
|
||||
substraction_mode_t domain_substraction_mode)
|
||||
{
|
||||
const size_t n_lhs = lhs.m_triplets.size();
|
||||
const size_t n_rhs = rhs.m_triplets.size();
|
||||
@ -226,7 +228,7 @@ Gtid GtidList::get_gtid(uint32_t domain) const
|
||||
// Make a dummy triplet for the domain search
|
||||
Gtid search_val(domain, -1, 0);
|
||||
auto found = std::lower_bound(m_triplets.begin(), m_triplets.end(), search_val,
|
||||
Gtid::compare_domains);
|
||||
Gtid::compare_domains);
|
||||
if (found != m_triplets.end() && found->m_domain == domain)
|
||||
{
|
||||
rval = *found;
|
||||
|
||||
@ -354,7 +354,7 @@ json_t* MariaDBMonitor::diagnostics_json() const
|
||||
json_object_set_new(srv, "gtid_binlog_pos",
|
||||
json_string(serv_info->gtid_binlog_pos.to_string().c_str()));
|
||||
json_object_set_new(srv, "gtid_io_pos",
|
||||
json_string(serv_info->slave_status.gtid_io_pos.to_string().c_str()));
|
||||
json_string(serv_info->slave_status.gtid_io_pos.to_string().c_str()));
|
||||
if (m_detect_multimaster)
|
||||
{
|
||||
json_object_set_new(srv, "master_group", json_integer(serv_info->group));
|
||||
@ -473,7 +473,7 @@ void MariaDBMonitor::main_loop()
|
||||
ss_dassert(root_master == NULL || root_master == m_master);
|
||||
ss_dassert(root_master == NULL ||
|
||||
((root_master->server_base->server->status & (SERVER_SLAVE | SERVER_MASTER)) !=
|
||||
(SERVER_SLAVE | SERVER_MASTER)));
|
||||
(SERVER_SLAVE | SERVER_MASTER)));
|
||||
|
||||
/**
|
||||
* After updating the status of all servers, check if monitor events
|
||||
@ -559,13 +559,13 @@ void MariaDBMonitor::update_external_master()
|
||||
if (m_external_master_port == PORT_UNKNOWN)
|
||||
{
|
||||
MXS_NOTICE("Cluster master server is replicating from an external master: %s:%d",
|
||||
new_ext_host.c_str(), new_ext_port);
|
||||
new_ext_host.c_str(), new_ext_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_NOTICE("The external master of the cluster has changed: %s:%d -> %s:%d.",
|
||||
m_external_master_host.c_str(), m_external_master_port,
|
||||
new_ext_host.c_str(), new_ext_port);
|
||||
m_external_master_host.c_str(), m_external_master_port,
|
||||
new_ext_host.c_str(), new_ext_port);
|
||||
}
|
||||
m_external_master_host = new_ext_host;
|
||||
m_external_master_port = new_ext_port;
|
||||
@ -593,7 +593,7 @@ void MariaDBMonitor::measure_replication_lag(MariaDBServer* root_master_server)
|
||||
{
|
||||
if (ptr->server->node_id != root_master->server->node_id &&
|
||||
(SERVER_IS_SLAVE(ptr->server) ||
|
||||
SERVER_IS_RELAY_SERVER(ptr->server)) &&
|
||||
SERVER_IS_RELAY_SERVER(ptr->server)) &&
|
||||
!(*iter)->binlog_relay) // No select lag for Binlog Server
|
||||
{
|
||||
set_slave_heartbeat(ptr);
|
||||
@ -643,15 +643,15 @@ void MariaDBMonitor::log_master_changes(MariaDBServer* root_master_server, int*
|
||||
!(root_master->server->status & SERVER_MAINT))
|
||||
{
|
||||
MXS_NOTICE("A Master Server is now available: %s:%i",
|
||||
root_master->server->name,
|
||||
root_master->server->port);
|
||||
root_master->server->name,
|
||||
root_master->server->port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("No Master can be determined. Last known was %s:%i",
|
||||
root_master->server->name,
|
||||
root_master->server->port);
|
||||
root_master->server->name,
|
||||
root_master->server->port);
|
||||
}
|
||||
*log_no_master = 1;
|
||||
}
|
||||
@ -869,7 +869,7 @@ void MariaDBMonitor::set_slave_heartbeat(MXS_MONITORED_SERVER *database)
|
||||
|
||||
/* if there is a master then send the query to the slave with master_id */
|
||||
if (m_master != NULL && (mxs_mysql_query(database->con, select_heartbeat_query) == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL))
|
||||
&& (result = mysql_store_result(database->con)) != NULL))
|
||||
{
|
||||
int rows_found = 0;
|
||||
|
||||
|
||||
@ -107,45 +107,44 @@ private:
|
||||
MXS_MONITOR* m_monitor_base; /**< Generic monitor object */
|
||||
THREAD m_thread; /**< Monitor thread */
|
||||
unsigned long m_id; /**< Monitor ID */
|
||||
volatile bool m_keep_running; /**< Set to false to cause monitor thread to exit. */
|
||||
volatile int m_status; /**< Monitor status. */
|
||||
ServerArray m_servers; /**< Servers of the monitor. */
|
||||
ServerInfoMap m_server_info; /**< Contains server specific information */
|
||||
volatile bool m_keep_running; /**< Should monitor main loop keep running? */
|
||||
volatile int m_status; /**< Monitor status */
|
||||
ServerArray m_servers; /**< Servers of the monitor */
|
||||
ServerInfoMap m_server_info; /**< Map from server base struct to MariaDBServer */
|
||||
|
||||
// Values updated by monitor
|
||||
int64_t m_master_gtid_domain; /**< Gtid domain currently used by the master */
|
||||
MariaDBServer* m_master; /**< Master server for Master/Slave replication */
|
||||
int64_t m_master_gtid_domain; /**< gtid_domain_id most recently seen on the master */
|
||||
std::string m_external_master_host; /**< External master host, for fail/switchover */
|
||||
int m_external_master_port; /**< External master port */
|
||||
MariaDBServer *m_master; /**< Master server for MySQL Master/Slave replication */
|
||||
|
||||
// Replication topology detection settings
|
||||
bool m_mysql51_replication; /**< Use MySQL 5.1 replication */
|
||||
bool m_allow_cluster_recovery; /**< Allow failed servers to rejoin the cluster */
|
||||
bool m_detect_replication_lag; /**< Monitor flag for MySQL replication heartbeat */
|
||||
bool m_detect_multimaster; /**< Detect and handle multi-master topologies */
|
||||
bool m_detect_stale_master; /**< Monitor flag for MySQL replication Stale Master detection */
|
||||
bool m_detect_stale_slave; /**< Monitor flag for MySQL replication Stale Slave detection */
|
||||
bool m_detect_multimaster; /**< Detect and handle multi-master topologies */
|
||||
bool m_ignore_external_masters; /**< Ignore masters outside of the monitor configuration */
|
||||
bool m_detect_standalone_master; /**< If standalone master are detected */
|
||||
bool m_allow_cluster_recovery; /**< Allow failed servers to rejoin the cluster */
|
||||
bool m_warn_set_standalone_master; /**< Log a warning when setting standalone master */
|
||||
bool m_ignore_external_masters; /**< Ignore masters outside of the monitor configuration */
|
||||
bool m_mysql51_replication; /**< Use MySQL 5.1 replication */
|
||||
|
||||
// Failover, switchover and rejoin settings
|
||||
bool m_auto_failover; /**< Is automatic master failover is enabled? */
|
||||
bool m_auto_rejoin; /**< Is automatic rejoin enabled? */
|
||||
int m_failcount; /**< Numer of cycles master must be down before auto-failover begins */
|
||||
std::string m_replication_user; /**< Replication user for CHANGE MASTER TO-commands */
|
||||
std::string m_replication_password; /**< Replication password for CHANGE MASTER TO-commands */
|
||||
int m_failcount; /**< How many monitoring cycles master must be down before auto-failover
|
||||
* begins */
|
||||
uint32_t m_failover_timeout; /**< Timeout in seconds for the master failover */
|
||||
uint32_t m_switchover_timeout; /**< Timeout in seconds for the master switchover */
|
||||
bool m_verify_master_failure; /**< Whether master failure is verified via slaves */
|
||||
uint32_t m_failover_timeout; /**< Time limit in seconds for master failover */
|
||||
uint32_t m_switchover_timeout; /**< Time limit in seconds for master switchover */
|
||||
bool m_verify_master_failure; /**< Is master failure is verified via slaves? */
|
||||
int m_master_failure_timeout; /**< Master failure verification (via slaves) time in seconds */
|
||||
bool m_auto_failover; /**< If automatic master failover is enabled */
|
||||
bool m_auto_rejoin; /**< Attempt to start slave replication on standalone servers or servers
|
||||
* replicating from the wrong master automatically. */
|
||||
ServerArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover. */
|
||||
ServerArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover or
|
||||
* autoselect switchover. */
|
||||
|
||||
// Other settings
|
||||
std::string m_script; /**< Script to call when state changes occur on servers */
|
||||
uint64_t m_events; /**< enabled events */
|
||||
bool m_detect_replication_lag; /**< Monitor flag for MySQL replication heartbeat */
|
||||
bool m_warn_set_standalone_master; /**< Log a warning when setting standalone master */
|
||||
|
||||
enum slave_down_setting_t
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user