MXS-2424 Use persisted nodes if bootstrap node missing

At runtime the Clustrix monitor will save to an sqlite3
database information about detected nodes and delete that
information if a node disappears.

At startup, if the monitor fails to connect to a bootstrap
node, it will try to connect any of the persisted nodes and
start from there.

This means that in general it is sufficient if the Clustrix
monitor at the very first startup can connect to a bootstrap
node; thereafter it will get by even if the bootstrap node
would disappear for good.
This commit is contained in:
Johan Wikman
2019-04-08 15:35:24 +03:00
parent 164ca7b5f1
commit 893059c537
3 changed files with 194 additions and 79 deletions

View File

@ -21,7 +21,8 @@
#include "clustrixmembership.hh"
#include "clustrixnode.hh"
class ClustrixMonitor : public maxscale::MonitorWorker
class ClustrixMonitor : public maxscale::MonitorWorker,
private ClustrixNode::Persister
{
ClustrixMonitor(const ClustrixMonitor&) = delete;
ClustrixMonitor& operator=(const ClustrixMonitor&) = delete;
@ -91,10 +92,12 @@ private:
bool choose_dynamic_hub(Clustrix::Softfailed softfailed, std::set<std::string>& ips_checked);
bool choose_bootstrap_hub(Clustrix::Softfailed softfailed, std::set<std::string>& ips_checked);
bool choose_persisted_hub(Clustrix::Softfailed softfailed, std::set<std::string>& ips_checked);
bool refresh_using_persisted_nodes(std::set<std::string>& ips_checked);
void refresh_nodes();
bool check_cluster_membership(std::map<int, ClustrixMembership>* pMemberships);
bool refresh_nodes();
bool refresh_nodes(MYSQL* pHub_con);
bool check_cluster_membership(MYSQL* pHub_con,
std::map<int, ClustrixMembership>* pMemberships);
void update_server_statuses();
@ -136,8 +139,9 @@ private:
return mxb::WorkerLoad::get_time_ms();
}
void persist_node(const ClustrixNode& node);
void unpersist_node(const ClustrixNode& node);
// ClustrixNode::Persister
void persist(const ClustrixNode& node);
void unpersist(const ClustrixNode& node);
private:
Config m_config;