MXS-1745 Save all rows from SHOW ALL SLAVES STATUS
The master down verification through slaves won't work with this commit. It needs to be redesigned to handle multiple slave connections or removed. Also, only the first row of slave status data is used by the monitor, so multiple slave connections are still incorrectly handled.
This commit is contained in:
parent
5f7257f432
commit
de1e299f3f
@ -390,12 +390,12 @@ void MariaDBMonitor::find_graph_cycles()
|
||||
/** Build the graph */
|
||||
for (int i = 0; i < nservers; i++)
|
||||
{
|
||||
if (graph[i].info->m_slave_status.master_server_id > 0)
|
||||
if (!graph[i].info->m_slave_status.empty() && graph[i].info->m_slave_status[0].master_server_id > 0)
|
||||
{
|
||||
/** Found a connected node */
|
||||
for (int k = 0; k < nservers; k++)
|
||||
{
|
||||
if (graph[k].info->m_server_id == graph[i].info->m_slave_status.master_server_id)
|
||||
if (graph[k].info->m_server_id == graph[i].info->m_slave_status[0].master_server_id)
|
||||
{
|
||||
graph[i].parent = &graph[k];
|
||||
break;
|
||||
@ -582,14 +582,15 @@ void MariaDBMonitor::monitor_mysql_db(MariaDBServer* serv_info)
|
||||
if (serv_info->do_show_slave_status())
|
||||
{
|
||||
/* If all configured slaves are running set this node as slave */
|
||||
if (serv_info->m_slave_configured && serv_info->m_n_slaves_running > 0 &&
|
||||
serv_info->m_n_slaves_running == serv_info->m_n_slaves_configured)
|
||||
if (serv_info->m_n_slaves_running > 0 &&
|
||||
serv_info->m_n_slaves_running == serv_info->m_slave_status.size())
|
||||
{
|
||||
monitor_set_pending_status(database, SERVER_SLAVE);
|
||||
}
|
||||
|
||||
/** Store master_id of current node. For MySQL 5.1 it will be set at a later point. */
|
||||
database->server->master_id = serv_info->m_slave_status.master_server_id;
|
||||
database->server->master_id = !serv_info->m_slave_status.empty() ?
|
||||
serv_info->m_slave_status[0].master_server_id : SERVER_ID_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@ -830,7 +831,7 @@ bool MariaDBMonitor::standalone_master_required()
|
||||
if (server->is_running())
|
||||
{
|
||||
candidates++;
|
||||
if (server->m_read_only || server->m_slave_configured || candidates > 1)
|
||||
if (server->m_read_only || !server->m_slave_status.empty() || candidates > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1084,7 +1085,7 @@ void MariaDBMonitor::update_server_states(MariaDBServer& db_server, MariaDBServe
|
||||
{
|
||||
monitor_set_pending_status(ptr, SERVER_SLAVE);
|
||||
}
|
||||
else if (root_master == NULL && serv_info->m_slave_configured)
|
||||
else if (root_master == NULL && !serv_info->m_slave_status.empty())
|
||||
{
|
||||
monitor_set_pending_status(ptr, SERVER_SLAVE);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t**
|
||||
const char* name = joinable->name();
|
||||
|
||||
bool op_success = false;
|
||||
if (joinable->m_n_slaves_configured == 0)
|
||||
if (joinable->m_slave_status.empty())
|
||||
{
|
||||
if (!m_demote_sql_file.empty() && !joinable->run_sql_from_file(m_demote_sql_file, output))
|
||||
{
|
||||
@ -413,15 +413,15 @@ bool MariaDBMonitor::server_is_rejoin_suspect(MariaDBServer* rejoin_cand, json_t
|
||||
bool is_suspect = false;
|
||||
if (rejoin_cand->is_running() && !rejoin_cand->is_master())
|
||||
{
|
||||
SlaveStatus* slave_status = &rejoin_cand->m_slave_status;
|
||||
// Has no slave connection, yet is not a master.
|
||||
if (rejoin_cand->m_n_slaves_configured == 0)
|
||||
if (rejoin_cand->m_slave_status.empty())
|
||||
{
|
||||
is_suspect = true;
|
||||
}
|
||||
// Or has existing slave connection ...
|
||||
else if (rejoin_cand->m_n_slaves_configured == 1)
|
||||
else if (rejoin_cand->m_slave_status.size() == 1)
|
||||
{
|
||||
SlaveStatus* slave_status = &rejoin_cand->m_slave_status[0];
|
||||
// which is connected to master but it's the wrong one
|
||||
if (slave_status->slave_io_running == SlaveStatus::SLAVE_IO_YES &&
|
||||
slave_status->master_server_id != m_master->m_server_id)
|
||||
@ -443,7 +443,7 @@ bool MariaDBMonitor::server_is_rejoin_suspect(MariaDBServer* rejoin_cand, json_t
|
||||
/* User has requested a manual rejoin but with a server which has multiple slave connections or
|
||||
* is already connected or trying to connect to the correct master. TODO: Slave IO stopped is
|
||||
* not yet handled perfectly. */
|
||||
if (rejoin_cand->m_n_slaves_configured > 1)
|
||||
if (rejoin_cand->m_slave_status.size() > 1)
|
||||
{
|
||||
const char MULTI_SLAVE[] = "Server '%s' has multiple slave connections, cannot rejoin.";
|
||||
PRINT_MXS_JSON_ERROR(output, MULTI_SLAVE, rejoin_cand->name());
|
||||
@ -915,14 +915,13 @@ bool MariaDBMonitor::wait_cluster_stabilization(MariaDBServer* new_master, const
|
||||
while (i >= 0)
|
||||
{
|
||||
MariaDBServer* slave = wait_list[i];
|
||||
if (slave->update_gtids() &&
|
||||
slave->do_show_slave_status())
|
||||
if (slave->update_gtids() && slave->do_show_slave_status() && !slave->m_slave_status.empty())
|
||||
{
|
||||
if (!slave->m_slave_status.last_error.empty())
|
||||
if (!slave->m_slave_status[0].last_error.empty())
|
||||
{
|
||||
// IO or SQL error on slave, replication is a fail
|
||||
MXS_WARNING("Slave '%s' cannot start replication: '%s'.", slave->name(),
|
||||
slave->m_slave_status.last_error.c_str());
|
||||
slave->m_slave_status[0].last_error.c_str());
|
||||
wait_list.erase(wait_list.begin() + i);
|
||||
repl_fails++;
|
||||
}
|
||||
@ -1154,9 +1153,9 @@ bool MariaDBMonitor::server_is_excluded(const MariaDBServer* server)
|
||||
bool MariaDBMonitor::is_candidate_better(const MariaDBServer* current_best, const MariaDBServer* candidate,
|
||||
uint32_t gtid_domain)
|
||||
{
|
||||
uint64_t cand_io = candidate->m_slave_status.gtid_io_pos.get_gtid(gtid_domain).m_sequence;
|
||||
uint64_t cand_io = candidate->m_slave_status[0].gtid_io_pos.get_gtid(gtid_domain).m_sequence;
|
||||
uint64_t cand_processed = candidate->m_gtid_current_pos.get_gtid(gtid_domain).m_sequence;
|
||||
uint64_t curr_io = current_best->m_slave_status.gtid_io_pos.get_gtid(gtid_domain).m_sequence;
|
||||
uint64_t curr_io = current_best->m_slave_status[0].gtid_io_pos.get_gtid(gtid_domain).m_sequence;
|
||||
uint64_t curr_processed = current_best->m_gtid_current_pos.get_gtid(gtid_domain).m_sequence;
|
||||
|
||||
bool cand_updates = candidate->m_rpl_settings.log_slave_updates;
|
||||
@ -1412,7 +1411,7 @@ bool MariaDBMonitor::failover_not_possible()
|
||||
{
|
||||
MariaDBServer* info = get_server_info(s);
|
||||
|
||||
if (info->m_n_slaves_configured > 1)
|
||||
if (info->m_slave_status.size() > 1)
|
||||
{
|
||||
MXS_ERROR("Server '%s' is configured to replicate from multiple "
|
||||
"masters, failover is not possible.", s->server->unique_name);
|
||||
@ -1437,9 +1436,9 @@ bool MariaDBMonitor::slave_receiving_events()
|
||||
{
|
||||
MariaDBServer* info = get_server_info(server);
|
||||
|
||||
if (info->m_slave_configured &&
|
||||
info->m_slave_status.slave_io_running == SlaveStatus::SLAVE_IO_YES &&
|
||||
info->m_slave_status.master_server_id == master_id &&
|
||||
if (!info->m_slave_status.empty() &&
|
||||
info->m_slave_status[0].slave_io_running == SlaveStatus::SLAVE_IO_YES &&
|
||||
info->m_slave_status[0].master_server_id == master_id &&
|
||||
difftime(time(NULL), info->m_latest_event) < m_master_failure_timeout)
|
||||
{
|
||||
/**
|
||||
|
@ -493,11 +493,12 @@ void MariaDBMonitor::update_external_master()
|
||||
{
|
||||
if (SERVER_IS_SLAVE_OF_EXTERNAL_MASTER(m_master->m_server_base->server))
|
||||
{
|
||||
if (m_master->m_slave_status.master_host != m_external_master_host ||
|
||||
m_master->m_slave_status.master_port != m_external_master_port)
|
||||
ss_dassert(!m_master->m_slave_status.empty());
|
||||
if (m_master->m_slave_status[0].master_host != m_external_master_host ||
|
||||
m_master->m_slave_status[0].master_port != m_external_master_port)
|
||||
{
|
||||
const string new_ext_host = m_master->m_slave_status.master_host;
|
||||
const int new_ext_port = m_master->m_slave_status.master_port;
|
||||
const string new_ext_host = m_master->m_slave_status[0].master_host;
|
||||
const int new_ext_port = m_master->m_slave_status[0].master_port;
|
||||
if (m_external_master_port == PORT_UNKNOWN)
|
||||
{
|
||||
MXS_NOTICE("Cluster master server is replicating from an external master: %s:%d",
|
||||
|
@ -43,9 +43,7 @@ MariaDBServer::MariaDBServer(MXS_MONITORED_SERVER* monitored_server)
|
||||
, m_server_id(SERVER_ID_UNKNOWN)
|
||||
, m_group(0)
|
||||
, m_read_only(false)
|
||||
, m_slave_configured(false)
|
||||
, m_binlog_relay(false)
|
||||
, m_n_slaves_configured(0)
|
||||
, m_n_slaves_running(0)
|
||||
, m_n_slave_heartbeats(0)
|
||||
, m_heartbeat_period(0)
|
||||
@ -61,8 +59,9 @@ int64_t MariaDBServer::relay_log_events()
|
||||
* rare but is possible (I guess?) if the server is replicating a domain from multiple masters
|
||||
* and decides to process events from one relay log before getting new events to the other. In
|
||||
* any case, such events are obsolete and the server can be considered to have processed such logs. */
|
||||
return GtidList::events_ahead(m_slave_status.gtid_io_pos, m_gtid_current_pos,
|
||||
GtidList::MISSING_DOMAIN_LHS_ADD);
|
||||
// TODO: Fix for multisource repl
|
||||
return !m_slave_status.empty() ? GtidList::events_ahead(m_slave_status[0].gtid_io_pos, m_gtid_current_pos,
|
||||
GtidList::MISSING_DOMAIN_LHS_ADD) : 0;
|
||||
}
|
||||
|
||||
std::auto_ptr<QueryResult> MariaDBServer::execute_query(const string& query)
|
||||
@ -134,81 +133,55 @@ bool MariaDBServer::do_show_slave_status()
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t i_slave_rec_hbs = -1, i_slave_hb_period = -1;
|
||||
int64_t i_connection_name = -1, i_slave_rec_hbs = -1, i_slave_hb_period = -1;
|
||||
int64_t i_using_gtid = -1, i_gtid_io_pos = -1;
|
||||
if (m_version == MARIADB_VERSION_100)
|
||||
{
|
||||
i_connection_name = result->get_col_index("Connection_name");
|
||||
i_slave_rec_hbs = result->get_col_index("Slave_received_heartbeats");
|
||||
i_slave_hb_period = result->get_col_index("Slave_heartbeat_period");
|
||||
i_using_gtid = result->get_col_index("Using_Gtid");
|
||||
i_gtid_io_pos = result->get_col_index("Gtid_IO_Pos");
|
||||
if (i_slave_rec_hbs < 0 || i_slave_hb_period < 0 || i_using_gtid < 0 || i_gtid_io_pos < 0)
|
||||
if (i_connection_name < 0 || i_slave_rec_hbs < 0 || i_slave_hb_period < 0 ||
|
||||
i_using_gtid < 0 || i_gtid_io_pos < 0)
|
||||
{
|
||||
MXS_ERROR(INVALID_DATA, query.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t master_server_id = SERVER_ID_UNKNOWN;
|
||||
int nconfigured = 0;
|
||||
m_slave_status.clear();
|
||||
int nrunning = 0;
|
||||
while (result->next_row())
|
||||
{
|
||||
nconfigured++;
|
||||
m_slave_status.master_host = result->get_string(i_master_host);
|
||||
m_slave_status.master_port = result->get_uint(i_master_port);
|
||||
SlaveStatus sstatus;
|
||||
sstatus.master_host = result->get_string(i_master_host);
|
||||
sstatus.master_port = result->get_uint(i_master_port);
|
||||
string last_io_error = result->get_string(i_last_io_error);
|
||||
string last_sql_error = result->get_string(i_last_sql_error);
|
||||
m_slave_status.last_error = !last_io_error.empty() ? last_io_error : last_sql_error;
|
||||
sstatus.last_error = !last_io_error.empty() ? last_io_error : last_sql_error;
|
||||
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
m_slave_status.slave_io_running =
|
||||
sstatus.slave_io_running =
|
||||
SlaveStatus::slave_io_from_string(result->get_string(i_slave_io_running));
|
||||
m_slave_status.slave_sql_running = (result->get_string(i_slave_sql_running) == "Yes");
|
||||
sstatus.slave_sql_running = (result->get_string(i_slave_sql_running) == "Yes");
|
||||
|
||||
if (m_slave_status.slave_io_running == SlaveStatus::SLAVE_IO_YES && m_slave_status.slave_sql_running)
|
||||
if (sstatus.slave_io_running == SlaveStatus::SLAVE_IO_YES)
|
||||
{
|
||||
if (nrunning == 0)
|
||||
// TODO: Fix for multisource replication, check changes to IO_Pos here and save somewhere.
|
||||
sstatus.master_server_id = result->get_uint(i_master_server_id);
|
||||
sstatus.master_log_file = result->get_string(i_master_log_file);
|
||||
sstatus.read_master_log_pos = result->get_uint(i_read_master_log_pos);
|
||||
if (sstatus.slave_sql_running)
|
||||
{
|
||||
/** Only check binlog name for the first running slave */
|
||||
string master_log_file = result->get_string(i_master_log_file);
|
||||
uint64_t read_master_log_pos = result->get_uint(i_read_master_log_pos);
|
||||
if (m_slave_status.master_log_file != master_log_file ||
|
||||
m_slave_status.read_master_log_pos != read_master_log_pos)
|
||||
{
|
||||
// IO thread is reading events from the master
|
||||
m_latest_event = time(NULL);
|
||||
}
|
||||
|
||||
m_slave_status.master_log_file = master_log_file;
|
||||
m_slave_status.read_master_log_pos = read_master_log_pos;
|
||||
}
|
||||
nrunning++;
|
||||
}
|
||||
|
||||
/* If Slave_IO_Running = Yes, assign the master_id to current server: this allows building
|
||||
* the replication tree, slaves ids will be added to master(s) and we will have at least the
|
||||
* root master server.
|
||||
* Please note, there could be no slaves at all if Slave_SQL_Running == 'No'
|
||||
*/
|
||||
int64_t last_io_errno = result->get_uint(i_last_io_errno);
|
||||
int io_errno = last_io_errno;
|
||||
const int connection_errno = 2003;
|
||||
|
||||
if (io_errno == 0 || io_errno == connection_errno)
|
||||
{
|
||||
/* Get Master_Server_Id */
|
||||
auto parsed = result->get_uint(i_master_server_id);
|
||||
if (parsed >= 0)
|
||||
{
|
||||
master_server_id = parsed;
|
||||
nrunning++;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_version == MARIADB_VERSION_100)
|
||||
{
|
||||
int heartbeats = result->get_uint(i_slave_rec_hbs);
|
||||
if (m_n_slave_heartbeats < heartbeats)
|
||||
sstatus.name = result->get_string(i_connection_name);
|
||||
auto heartbeats = result->get_uint(i_slave_rec_hbs);
|
||||
if (m_n_slave_heartbeats < heartbeats) // TODO: Fix for multisource replication
|
||||
{
|
||||
m_latest_event = time(NULL);
|
||||
m_n_slave_heartbeats = heartbeats;
|
||||
@ -219,29 +192,18 @@ bool MariaDBServer::do_show_slave_status()
|
||||
if (!gtid_io_pos.empty() &&
|
||||
(using_gtid == "Current_Pos" || using_gtid == "Slave_Pos"))
|
||||
{
|
||||
m_slave_status.gtid_io_pos = GtidList::from_string(gtid_io_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_slave_status.gtid_io_pos = GtidList();
|
||||
sstatus.gtid_io_pos = GtidList::from_string(gtid_io_pos);
|
||||
}
|
||||
}
|
||||
m_slave_status.push_back(sstatus);
|
||||
}
|
||||
|
||||
if (nconfigured > 0)
|
||||
{
|
||||
m_slave_configured = true;
|
||||
}
|
||||
else
|
||||
if (m_slave_status.empty())
|
||||
{
|
||||
/** Query returned no rows, replication is not configured */
|
||||
m_slave_configured = false;
|
||||
m_n_slave_heartbeats = 0;
|
||||
m_slave_status = SlaveStatus();
|
||||
}
|
||||
|
||||
m_slave_status.master_server_id = master_server_id;
|
||||
m_n_slaves_configured = nconfigured;
|
||||
m_n_slaves_running = nrunning;
|
||||
return true;
|
||||
}
|
||||
@ -448,15 +410,15 @@ string MariaDBServer::diagnostics(bool multimaster) const
|
||||
ss << "Server: " << name() << "\n";
|
||||
ss << "Server ID: " << m_server_id << "\n";
|
||||
ss << "Read only: " << (m_read_only ? "YES" : "NO") << "\n";
|
||||
ss << "Slave configured: " << (m_slave_configured ? "YES" : "NO") << "\n";
|
||||
if (m_slave_configured)
|
||||
ss << "Slave configured: " << (!m_slave_status.empty() ? "YES" : "NO") << "\n";
|
||||
if (!m_slave_status.empty())
|
||||
{
|
||||
ss << "Slave IO running: " <<
|
||||
SlaveStatus::slave_io_to_string(m_slave_status.slave_io_running) << "\n";
|
||||
ss << "Slave SQL running: " << (m_slave_status.slave_sql_running ? "YES" : "NO") << "\n";
|
||||
ss << "Master ID: " << m_slave_status.master_server_id << "\n";
|
||||
ss << "Master binlog file: " << m_slave_status.master_log_file << "\n";
|
||||
ss << "Master binlog position: " << m_slave_status.read_master_log_pos << "\n";
|
||||
SlaveStatus::slave_io_to_string(m_slave_status[0].slave_io_running) << "\n";
|
||||
ss << "Slave SQL running: " << (m_slave_status[0].slave_sql_running ? "YES" : "NO") << "\n";
|
||||
ss << "Master ID: " << m_slave_status[0].master_server_id << "\n";
|
||||
ss << "Master binlog file: " << m_slave_status[0].master_log_file << "\n";
|
||||
ss << "Master binlog position: " << m_slave_status[0].read_master_log_pos << "\n";
|
||||
}
|
||||
if (!m_gtid_current_pos.empty())
|
||||
{
|
||||
@ -466,9 +428,9 @@ string MariaDBServer::diagnostics(bool multimaster) const
|
||||
{
|
||||
ss << "Gtid binlog position: " << m_gtid_binlog_pos.to_string() << "\n";
|
||||
}
|
||||
if (!m_slave_status.gtid_io_pos.empty())
|
||||
if (!m_slave_status.empty() && !m_slave_status[0].gtid_io_pos.empty())
|
||||
{
|
||||
ss << "Gtid slave IO position: " << m_slave_status.gtid_io_pos.to_string() << "\n";
|
||||
ss << "Gtid slave IO position: " << m_slave_status[0].gtid_io_pos.to_string() << "\n";
|
||||
}
|
||||
if (multimaster)
|
||||
{
|
||||
@ -482,19 +444,32 @@ json_t* MariaDBServer::diagnostics_json(bool multimaster) const
|
||||
json_t* srv = json_object();
|
||||
json_object_set_new(srv, "name", json_string(name()));
|
||||
json_object_set_new(srv, "server_id", json_integer(m_server_id));
|
||||
json_object_set_new(srv, "master_id", json_integer(m_slave_status.master_server_id));
|
||||
|
||||
json_object_set_new(srv, "read_only", json_boolean(m_read_only));
|
||||
json_object_set_new(srv, "slave_configured", json_boolean(m_slave_configured));
|
||||
json_object_set_new(srv, "slave_io_running",
|
||||
json_string(SlaveStatus::slave_io_to_string(m_slave_status.slave_io_running).c_str()));
|
||||
json_object_set_new(srv, "slave_sql_running", json_boolean(m_slave_status.slave_sql_running));
|
||||
|
||||
json_object_set_new(srv, "master_binlog_file", json_string(m_slave_status.master_log_file.c_str()));
|
||||
json_object_set_new(srv, "master_binlog_position", json_integer(m_slave_status.read_master_log_pos));
|
||||
json_object_set_new(srv, "gtid_current_pos", json_string(m_gtid_current_pos.to_string().c_str()));
|
||||
json_object_set_new(srv, "gtid_binlog_pos", json_string(m_gtid_binlog_pos.to_string().c_str()));
|
||||
json_object_set_new(srv, "gtid_io_pos", json_string(m_slave_status.gtid_io_pos.to_string().c_str()));
|
||||
json_object_set_new(srv, "slave_configured", json_boolean(!m_slave_status.empty()));
|
||||
if (!m_slave_status.empty())
|
||||
{
|
||||
json_object_set_new(srv, "slave_io_running",
|
||||
json_string(SlaveStatus::slave_io_to_string(m_slave_status[0].slave_io_running).c_str()));
|
||||
json_object_set_new(srv, "slave_sql_running", json_boolean(m_slave_status[0].slave_sql_running));
|
||||
json_object_set_new(srv, "master_id", json_integer(m_slave_status[0].master_server_id));
|
||||
json_object_set_new(srv, "master_binlog_file",
|
||||
json_string(m_slave_status[0].master_log_file.c_str()));
|
||||
json_object_set_new(srv, "master_binlog_position",
|
||||
json_integer(m_slave_status[0].read_master_log_pos));
|
||||
}
|
||||
if (!m_gtid_current_pos.empty())
|
||||
{
|
||||
json_object_set_new(srv, "gtid_current_pos", json_string(m_gtid_current_pos.to_string().c_str()));
|
||||
}
|
||||
if (!m_gtid_binlog_pos.empty())
|
||||
{
|
||||
json_object_set_new(srv, "gtid_binlog_pos", json_string(m_gtid_binlog_pos.to_string().c_str()));
|
||||
}
|
||||
if (!m_slave_status.empty() && !m_slave_status[0].gtid_io_pos.empty())
|
||||
{
|
||||
json_object_set_new(srv, "gtid_io_pos",
|
||||
json_string(m_slave_status[0].gtid_io_pos.to_string().c_str()));
|
||||
}
|
||||
if (multimaster)
|
||||
{
|
||||
json_object_set_new(srv, "master_group", json_integer(m_group));
|
||||
@ -504,7 +479,7 @@ json_t* MariaDBServer::diagnostics_json(bool multimaster) const
|
||||
|
||||
bool MariaDBServer::uses_gtid(json_t** error_out)
|
||||
{
|
||||
bool using_gtid = !m_slave_status.gtid_io_pos.empty();
|
||||
bool using_gtid = !m_slave_status.empty() && !m_slave_status[0].gtid_io_pos.empty();
|
||||
if (!using_gtid)
|
||||
{
|
||||
string slave_not_gtid_msg = string("Slave server ") + name() + " is not using gtid replication.";
|
||||
@ -515,7 +490,8 @@ bool MariaDBServer::uses_gtid(json_t** error_out)
|
||||
|
||||
bool MariaDBServer::update_slave_info()
|
||||
{
|
||||
return (m_slave_status.slave_sql_running && update_replication_settings() &&
|
||||
// TODO: fix for multisource repl
|
||||
return (!m_slave_status.empty() && m_slave_status[0].slave_sql_running && update_replication_settings() &&
|
||||
update_gtids() && do_show_slave_status());
|
||||
}
|
||||
|
||||
@ -614,12 +590,13 @@ bool MariaDBServer::failover_wait_relay_log(int seconds_remaining, json_t** err_
|
||||
MXS_INFO("Relay log of server '%s' not yet empty, waiting to clear %" PRId64 " events.",
|
||||
name(), relay_log_events());
|
||||
thread_millisleep(1000); // Sleep for a while before querying server again.
|
||||
// Todo: check server version before entering failover.
|
||||
GtidList old_gtid_io_pos = m_slave_status.gtid_io_pos;
|
||||
// TODO: check server version before entering failover.
|
||||
// TODO: fix for multisource
|
||||
GtidList old_gtid_io_pos = m_slave_status[0].gtid_io_pos;
|
||||
// Update gtid:s first to make sure Gtid_IO_Pos is the more recent value.
|
||||
// It doesn't matter here, but is a general rule.
|
||||
query_ok = update_gtids() && do_show_slave_status();
|
||||
io_pos_stable = (old_gtid_io_pos == m_slave_status.gtid_io_pos);
|
||||
io_pos_stable = (old_gtid_io_pos == m_slave_status[0].gtid_io_pos);
|
||||
}
|
||||
|
||||
bool rval = false;
|
||||
@ -641,7 +618,7 @@ bool MariaDBServer::failover_wait_relay_log(int seconds_remaining, json_t** err_
|
||||
else if (relay_log_events() < 0) // TODO: This is currently impossible
|
||||
{
|
||||
reason = "Invalid Gtid(s) (current_pos: " + m_gtid_current_pos.to_string() +
|
||||
", io_pos: " + m_slave_status.gtid_io_pos.to_string() + ")";
|
||||
", io_pos: " + m_slave_status[0].gtid_io_pos.to_string() + ")";
|
||||
}
|
||||
PRINT_MXS_JSON_ERROR(err_out, "Failover: %s while waiting for server '%s' to process relay log. "
|
||||
"Cancelling failover.", reason.c_str(), name());
|
||||
@ -797,14 +774,14 @@ int64_t QueryResult::get_col_index(const string& col_name) const
|
||||
|
||||
string QueryResult::get_string(int64_t column_ind) const
|
||||
{
|
||||
ss_dassert(column_ind < m_columns);
|
||||
ss_dassert(column_ind < m_columns && column_ind >= 0);
|
||||
char* data = m_rowdata[column_ind];
|
||||
return data ? data : "";
|
||||
}
|
||||
|
||||
int64_t QueryResult::get_uint(int64_t column_ind) const
|
||||
{
|
||||
ss_dassert(column_ind < m_columns);
|
||||
ss_dassert(column_ind < m_columns && column_ind >= 0);
|
||||
char* data = m_rowdata[column_ind];
|
||||
int64_t rval = -1;
|
||||
if (data && *data)
|
||||
@ -822,7 +799,7 @@ int64_t QueryResult::get_uint(int64_t column_ind) const
|
||||
|
||||
bool QueryResult::get_bool(int64_t column_ind) const
|
||||
{
|
||||
ss_dassert(column_ind < m_columns);
|
||||
ss_dassert(column_ind < m_columns && column_ind >= 0);
|
||||
char* data = m_rowdata[column_ind];
|
||||
return data ? (strcmp(data,"Y") == 0 || strcmp(data, "1") == 0) : false;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
SLAVE_IO_NO,
|
||||
};
|
||||
|
||||
std::string name; /**< Slave connection name. Must be unique. */
|
||||
int64_t master_server_id; /**< The master's server_id value. Valid ids are 32bit unsigned. -1 is
|
||||
* unread/error. */
|
||||
std::string master_host; /**< Master server host name. */
|
||||
@ -76,6 +77,7 @@ public:
|
||||
class MariaDBServer
|
||||
{
|
||||
public:
|
||||
typedef std::vector<SlaveStatus> SlaveStatusArray;
|
||||
enum mariadb_version
|
||||
{
|
||||
MARIADB_VERSION_UNKNOWN, // Anything older than 5.5. These are no longer supported by the monitor.
|
||||
@ -91,10 +93,8 @@ public:
|
||||
int m_group; /**< Multi-master group where this server belongs,
|
||||
* 0 for servers not in groups */
|
||||
bool m_read_only; /**< Value of @@read_only */
|
||||
bool m_slave_configured; /**< Whether SHOW SLAVE STATUS returned rows */
|
||||
bool m_binlog_relay; /** Server is a Binlog Relay */
|
||||
int m_n_slaves_configured; /**< Number of configured slave connections*/
|
||||
int m_n_slaves_running; /**< Number of running slave connections */
|
||||
size_t m_n_slaves_running; /**< Number of running slave connections */
|
||||
int m_n_slave_heartbeats; /**< Number of received heartbeats */
|
||||
double m_heartbeat_period; /**< The time interval between heartbeats */
|
||||
time_t m_latest_event; /**< Time when latest event was received from the master */
|
||||
@ -102,7 +102,7 @@ public:
|
||||
* new non-replicated events. */
|
||||
GtidList m_gtid_current_pos; /**< Gtid of latest event. */
|
||||
GtidList m_gtid_binlog_pos; /**< Gtid of latest event written to binlog. */
|
||||
SlaveStatus m_slave_status; /**< Data returned from SHOW SLAVE STATUS */
|
||||
SlaveStatusArray m_slave_status; /**< Data returned from SHOW SLAVE STATUS */
|
||||
ReplicationSettings m_rpl_settings; /**< Miscellaneous replication related settings */
|
||||
|
||||
MariaDBServer(MXS_MONITORED_SERVER* monitored_server);
|
||||
|
Loading…
x
Reference in New Issue
Block a user