Remove old "detect_standalone_master"-feature, update documentation
The auto_failover is a more reliable solution and should be used instead. Several unused parameters were removed, although they can still be defined in the config file. Updated documentation on the relevant parts.
This commit is contained in:
@ -463,78 +463,6 @@ static bool check_replicate_wild_ignore_table(MXS_MONITORED_SERVER* database)
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check whether standalone master conditions have been met
|
||||
*
|
||||
* This function checks whether all the conditions to use a standalone master are met. For this to happen,
|
||||
* only one server must be available and other servers must have passed the configured tolerance level of
|
||||
* failures.
|
||||
*
|
||||
* @return True if standalone master should be used
|
||||
*/
|
||||
bool MariaDBMonitor::standalone_master_required()
|
||||
{
|
||||
int candidates = 0;
|
||||
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
||||
{
|
||||
MariaDBServer* server = *iter;
|
||||
if (server->is_running())
|
||||
{
|
||||
candidates++;
|
||||
if (server->m_read_only || !server->m_slave_status.empty() || candidates > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (server->m_server_base->mon_err_count < m_failcount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return candidates == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Use standalone master
|
||||
*
|
||||
* This function assigns the last remaining server the master status and sets all other servers into
|
||||
* maintenance mode. By setting the servers into maintenance mode, we prevent any possible conflicts when
|
||||
* the failed servers come back up.
|
||||
*
|
||||
* @return True if standalone master was set
|
||||
*/
|
||||
bool MariaDBMonitor::set_standalone_master()
|
||||
{
|
||||
bool rval = false;
|
||||
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
||||
{
|
||||
MariaDBServer* server = *iter;
|
||||
auto mon_server = server->m_server_base;
|
||||
if (server->is_running())
|
||||
{
|
||||
if (!server->is_master() && m_warn_set_standalone_master)
|
||||
{
|
||||
MXS_WARNING("Setting standalone master, server '%s' is now the master.%s",
|
||||
server->name(), m_allow_cluster_recovery ? "" :
|
||||
" All other servers are set into maintenance mode.");
|
||||
m_warn_set_standalone_master = false;
|
||||
}
|
||||
|
||||
monitor_set_pending_status(mon_server, SERVER_MASTER | SERVER_WAS_MASTER);
|
||||
monitor_clear_pending_status(mon_server, SERVER_SLAVE);
|
||||
m_master = server;
|
||||
rval = true;
|
||||
}
|
||||
else if (!m_allow_cluster_recovery)
|
||||
{
|
||||
server->set_status(SERVER_MAINT);
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the server with the best reach in the candidates-array. Running state or 'read_only' is ignored by
|
||||
* this method.
|
||||
|
||||
@ -42,6 +42,7 @@ static const char CN_NO_PROMOTE_SERVERS[] = "servers_no_promotion";
|
||||
static const char CN_FAILOVER_TIMEOUT[] = "failover_timeout";
|
||||
static const char CN_SWITCHOVER_ON_LOW_DISK_SPACE[] = "switchover_on_low_disk_space";
|
||||
static const char CN_SWITCHOVER_TIMEOUT[] = "switchover_timeout";
|
||||
static const char CN_DETECT_STANDALONE_MASTER[] = "detect_standalone_master";
|
||||
static const char CN_MAINTENANCE_ON_LOW_DISK_SPACE[] = "maintenance_on_low_disk_space";
|
||||
// Parameters for master failure verification and timeout
|
||||
static const char CN_VERIFY_MASTER_FAILURE[] = "verify_master_failure";
|
||||
@ -58,7 +59,6 @@ MariaDBMonitor::MariaDBMonitor(MXS_MONITOR* monitor)
|
||||
, m_cluster_topology_changed(true)
|
||||
, m_cluster_modified(false)
|
||||
, m_switchover_on_low_disk_space(false)
|
||||
, m_warn_set_standalone_master(true)
|
||||
, m_log_no_master(true)
|
||||
, m_warn_failover_precond(true)
|
||||
, m_warn_cannot_rejoin(true)
|
||||
@ -181,11 +181,9 @@ bool MariaDBMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
m_detect_stale_master = config_get_bool(params, "detect_stale_master");
|
||||
m_detect_stale_slave = config_get_bool(params, "detect_stale_slave");
|
||||
m_detect_replication_lag = config_get_bool(params, "detect_replication_lag");
|
||||
m_detect_multimaster = config_get_bool(params, "multimaster");
|
||||
m_ignore_external_masters = config_get_bool(params, "ignore_external_masters");
|
||||
m_detect_standalone_master = config_get_bool(params, "detect_standalone_master");
|
||||
m_detect_standalone_master = config_get_bool(params, CN_DETECT_STANDALONE_MASTER);
|
||||
m_failcount = config_get_integer(params, CN_FAILCOUNT);
|
||||
m_allow_cluster_recovery = config_get_bool(params, "allow_cluster_recovery");
|
||||
m_script = config_get_string(params, "script");
|
||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
m_failover_timeout = config_get_integer(params, CN_FAILOVER_TIMEOUT);
|
||||
@ -244,7 +242,7 @@ void MariaDBMonitor::diagnostics(DCB *dcb) const
|
||||
dcb_printf(dcb, "\nServer information:\n-------------------\n\n");
|
||||
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
||||
{
|
||||
string server_info = (*iter)->diagnostics(m_detect_multimaster) + "\n";
|
||||
string server_info = (*iter)->diagnostics() + "\n";
|
||||
dcb_printf(dcb, "%s", server_info.c_str());
|
||||
}
|
||||
}
|
||||
@ -256,10 +254,8 @@ json_t* MariaDBMonitor::diagnostics_json() const
|
||||
json_object_set_new(rval, "detect_stale_master", json_boolean(m_detect_stale_master));
|
||||
json_object_set_new(rval, "detect_stale_slave", json_boolean(m_detect_stale_slave));
|
||||
json_object_set_new(rval, "detect_replication_lag", json_boolean(m_detect_replication_lag));
|
||||
json_object_set_new(rval, "multimaster", json_boolean(m_detect_multimaster));
|
||||
json_object_set_new(rval, "detect_standalone_master", json_boolean(m_detect_standalone_master));
|
||||
json_object_set_new(rval, CN_DETECT_STANDALONE_MASTER, json_boolean(m_detect_standalone_master));
|
||||
json_object_set_new(rval, CN_FAILCOUNT, json_integer(m_failcount));
|
||||
json_object_set_new(rval, "allow_cluster_recovery", json_boolean(m_allow_cluster_recovery));
|
||||
json_object_set_new(rval, CN_AUTO_FAILOVER, json_boolean(m_auto_failover));
|
||||
json_object_set_new(rval, CN_FAILOVER_TIMEOUT, json_integer(m_failover_timeout));
|
||||
json_object_set_new(rval, CN_SWITCHOVER_TIMEOUT, json_integer(m_switchover_timeout));
|
||||
@ -281,7 +277,7 @@ json_t* MariaDBMonitor::diagnostics_json() const
|
||||
json_t* arr = json_array();
|
||||
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
||||
{
|
||||
json_array_append_new(arr, (*iter)->diagnostics_json(m_detect_multimaster));
|
||||
json_array_append_new(arr, (*iter)->diagnostics_json());
|
||||
}
|
||||
json_object_set_new(rval, "server_info", arr);
|
||||
}
|
||||
@ -491,20 +487,6 @@ void MariaDBMonitor::tick()
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if need to use standalone master. TODO: Rewrite these methods. */
|
||||
if (m_detect_standalone_master)
|
||||
{
|
||||
if (standalone_master_required())
|
||||
{
|
||||
// Other servers have died, set last remaining server as master
|
||||
set_standalone_master();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_warn_set_standalone_master = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_master != NULL && m_master->is_master())
|
||||
{
|
||||
// Update cluster-wide values dependant on the current master.
|
||||
@ -1273,10 +1255,10 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{"detect_stale_master", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"detect_stale_slave", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"mysql51_replication", MXS_MODULE_PARAM_BOOL, "false", MXS_MODULE_OPT_DEPRECATED},
|
||||
{"multimaster", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"detect_standalone_master", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"multimaster", MXS_MODULE_PARAM_BOOL, "false", MXS_MODULE_OPT_DEPRECATED},
|
||||
{CN_DETECT_STANDALONE_MASTER, MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{CN_FAILCOUNT, MXS_MODULE_PARAM_COUNT, "5"},
|
||||
{"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true", MXS_MODULE_OPT_DEPRECATED},
|
||||
{"ignore_external_masters", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{
|
||||
"script",
|
||||
|
||||
@ -143,14 +143,11 @@ private:
|
||||
CycleInfo m_master_cycle_status; /**< Info about master server cycle from previous round */
|
||||
|
||||
// Replication topology detection settings
|
||||
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_standalone_master; /**< If standalone master are detected */
|
||||
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? */
|
||||
@ -174,7 +171,6 @@ private:
|
||||
// Other settings
|
||||
std::string m_script; /**< Script to call when state changes occur on servers */
|
||||
uint64_t m_events; /**< enabled events */
|
||||
bool m_warn_set_standalone_master; /**< Log a warning when setting standalone master */
|
||||
bool m_log_no_master; /**< Should it be logged that there is no master */
|
||||
bool m_warn_no_valid_in_cycle; /**< Log a warning when a replication cycle has no valid master */
|
||||
bool m_warn_no_valid_outside_cycle; /**< Log a warning when a replication topology has no valid master
|
||||
@ -196,8 +192,6 @@ private:
|
||||
// Cluster discovery and status assignment methods
|
||||
void update_server(MariaDBServer& server);
|
||||
void find_graph_cycles();
|
||||
bool standalone_master_required();
|
||||
bool set_standalone_master();
|
||||
void log_master_changes();
|
||||
void update_gtid_domain();
|
||||
void update_external_master();
|
||||
|
||||
@ -487,7 +487,7 @@ const char* MariaDBServer::name() const
|
||||
return m_server_base->server->name;
|
||||
}
|
||||
|
||||
string MariaDBServer::diagnostics(bool multimaster) const
|
||||
string MariaDBServer::diagnostics() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Server: " << name() << "\n";
|
||||
@ -507,14 +507,14 @@ string MariaDBServer::diagnostics(bool multimaster) const
|
||||
{
|
||||
ss << "Gtid binlog position: " << m_gtid_binlog_pos.to_string() << "\n";
|
||||
}
|
||||
if (multimaster)
|
||||
if (m_node.cycle != NodeData::CYCLE_NONE)
|
||||
{
|
||||
ss << "Master group: " << m_node.cycle << "\n";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
json_t* MariaDBServer::diagnostics_json(bool multimaster) const
|
||||
json_t* MariaDBServer::diagnostics_json() const
|
||||
{
|
||||
json_t* srv = json_object();
|
||||
json_object_set_new(srv, "name", json_string(name()));
|
||||
@ -541,7 +541,7 @@ json_t* MariaDBServer::diagnostics_json(bool multimaster) const
|
||||
json_object_set_new(srv, "gtid_io_pos",
|
||||
json_string(m_slave_status[0].gtid_io_pos.to_string().c_str()));
|
||||
}
|
||||
if (multimaster)
|
||||
if (m_node.cycle != NodeData::CYCLE_NONE)
|
||||
{
|
||||
json_object_set_new(srv, "master_group", json_integer(m_node.cycle));
|
||||
}
|
||||
|
||||
@ -299,18 +299,16 @@ public:
|
||||
/**
|
||||
* Print server information to a json object.
|
||||
*
|
||||
* @param multimaster Print multimaster group
|
||||
* @return Json diagnostics object
|
||||
*/
|
||||
json_t* diagnostics_json(bool multimaster) const;
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
/**
|
||||
* Print server information to a string.
|
||||
*
|
||||
* @param multimaster Print multimaster group
|
||||
* @return Diagnostics string
|
||||
*/
|
||||
std::string diagnostics(bool multimaster) const;
|
||||
std::string diagnostics() const;
|
||||
|
||||
/**
|
||||
* Check if server is using gtid replication.
|
||||
|
||||
Reference in New Issue
Block a user