MXS-2219 Use system.membership as primary table

From system.membership we can find out what server exist in the
cluster while system.nodeinfo contains information about those
servers. If a node goes down, it will disappear from system.nodeinfo,
but not from system.membership. Consequently, we must start from
system.membership and then fetch more information from system.nodeinfo.

Incidentally, a query like

    SELECT ms.nid, ni.iface_ip
    FROM system.membership AS ms
        LEFT JOIN system.nodeinfo AS ni ON ms.nid=ni.nodeid;

should provide all information in one go, but it seems that such joins
are not supported on the system tables.
This commit is contained in:
Johan Wikman
2019-01-17 16:58:05 +02:00
parent f7c840df26
commit 6b556859ce
8 changed files with 564 additions and 163 deletions

View File

@ -16,7 +16,8 @@
#include <map>
#include <maxscale/monitor.hh>
#include <maxbase/http.hh>
#include "clustrixnodeinfo.hh"
#include "clustrixmembership.hh"
#include "clustrixnode.hh"
class ClustrixMonitor : public maxscale::MonitorInstance
{
@ -71,9 +72,10 @@ private:
void tick();
void fetch_cluster_nodes();
void fetch_cluster_nodes_from(MXS_MONITORED_SERVER& ms);
void update_cluster_nodes();
void update_cluster_nodes(MXS_MONITORED_SERVER& ms);
void refresh_cluster_nodes();
bool check_cluster_membership(MXS_MONITORED_SERVER& ms, std::map<int, ClustrixMembership>* pMemberships);
void update_server_statuses();
void make_health_check();
@ -86,12 +88,11 @@ private:
}
private:
Config m_config;
std::vector<std::string> m_config_servers;
std::map<int, ClustrixNodeInfo> m_node_infos;
std::vector<std::string> m_health_urls;
mxb::http::Async m_http;
uint32_t m_delayed_http_check_id { 0 };
long m_last_cluster_check { 0 };
MXS_MONITORED_SERVER* m_pMonitored_server { nullptr };
Config m_config;
std::map<int, ClustrixNode> m_nodes;
std::vector<std::string> m_health_urls;
mxb::http::Async m_http;
uint32_t m_delayed_http_check_id { 0 };
long m_last_cluster_check { 0 };
MXS_MONITORED_SERVER* m_pMonitored_server { nullptr };
};