Fixed a possible bug with multiple monitors monitoring the same servers.
This commit is contained in:
@ -64,6 +64,7 @@ static void diagnostics(DCB *, void *);
|
|||||||
static MONITOR_SERVERS *get_candidate_master(MONITOR_SERVERS *);
|
static MONITOR_SERVERS *get_candidate_master(MONITOR_SERVERS *);
|
||||||
static MONITOR_SERVERS *set_cluster_master(MONITOR_SERVERS *, MONITOR_SERVERS *, int);
|
static MONITOR_SERVERS *set_cluster_master(MONITOR_SERVERS *, MONITOR_SERVERS *, int);
|
||||||
static void disableMasterFailback(void *, int);
|
static void disableMasterFailback(void *, int);
|
||||||
|
bool isGaleraEvent(monitor_event_t event);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = {
|
static MONITOR_OBJECT MyObject = {
|
||||||
startMonitor,
|
startMonitor,
|
||||||
@ -570,15 +571,19 @@ monitor_event_t evtype;
|
|||||||
{
|
{
|
||||||
|
|
||||||
/** Execute monitor script if a server state has changed */
|
/** Execute monitor script if a server state has changed */
|
||||||
if(mon_status_changed(ptr) && (evtype = mon_get_event_type(ptr)) != UNDEFINED_MONITOR_EVENT)
|
if(mon_status_changed(ptr))
|
||||||
{
|
{
|
||||||
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
evtype = mon_get_event_type(ptr);
|
||||||
ptr->server->unique_name,
|
if(isGaleraEvent(evtype))
|
||||||
ptr->server->name,ptr->server->port,
|
|
||||||
mon_get_event_name(ptr));
|
|
||||||
if(handle->script && handle->events[evtype])
|
|
||||||
{
|
{
|
||||||
monitor_launch_script(mon,ptr,handle->script);
|
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
||||||
|
ptr->server->unique_name,
|
||||||
|
ptr->server->name,ptr->server->port,
|
||||||
|
mon_get_event_name(ptr));
|
||||||
|
if(handle->script && handle->events[evtype])
|
||||||
|
{
|
||||||
|
monitor_launch_script(mon,ptr,handle->script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@ -687,3 +692,40 @@ availableWhenDonor(void *arg, int disable)
|
|||||||
GALERA_MONITOR *handle = (GALERA_MONITOR *)arg;
|
GALERA_MONITOR *handle = (GALERA_MONITOR *)arg;
|
||||||
memcpy(&handle->availableWhenDonor, &disable, sizeof(int));
|
memcpy(&handle->availableWhenDonor, &disable, sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static monitor_event_t galera_events[] = {
|
||||||
|
MASTER_DOWN_EVENT,
|
||||||
|
MASTER_UP_EVENT,
|
||||||
|
SLAVE_DOWN_EVENT,
|
||||||
|
SLAVE_UP_EVENT,
|
||||||
|
SERVER_DOWN_EVENT,
|
||||||
|
SERVER_UP_EVENT,
|
||||||
|
SYNCED_DOWN_EVENT,
|
||||||
|
SYNCED_UP_EVENT,
|
||||||
|
DONOR_DOWN_EVENT,
|
||||||
|
DONOR_UP_EVENT,
|
||||||
|
LOST_MASTER_EVENT,
|
||||||
|
LOST_SLAVE_EVENT,
|
||||||
|
LOST_SYNCED_EVENT,
|
||||||
|
LOST_DONOR_EVENT,
|
||||||
|
NEW_MASTER_EVENT,
|
||||||
|
NEW_SLAVE_EVENT,
|
||||||
|
NEW_SYNCED_EVENT,
|
||||||
|
NEW_DONOR_EVENT,
|
||||||
|
MAX_MONITOR_EVENT
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Check if the Galera monitor is monitoring this event type.
|
||||||
|
* @param event Event to check
|
||||||
|
* @return True if the event is monitored, false if it is not
|
||||||
|
* */
|
||||||
|
bool isGaleraEvent(monitor_event_t event)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0;galera_events[i] != MAX_MONITOR_EVENT;i++)
|
||||||
|
{
|
||||||
|
if(event == galera_events[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -594,16 +594,19 @@ size_t nrounds = 0;
|
|||||||
monitor_event_t evtype;
|
monitor_event_t evtype;
|
||||||
while(ptr)
|
while(ptr)
|
||||||
{
|
{
|
||||||
/** Execute monitor script if a server state has changed */
|
if(mon_status_changed(ptr))
|
||||||
if(mon_status_changed(ptr) && (evtype = mon_get_event_type(ptr)) != UNDEFINED_MONITOR_EVENT)
|
|
||||||
{
|
{
|
||||||
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
evtype = mon_get_event_type(ptr);
|
||||||
ptr->server->unique_name,
|
if(isMySQLEvent(evtype))
|
||||||
ptr->server->name,ptr->server->port,
|
|
||||||
mon_get_event_name(ptr));
|
|
||||||
if(handle->script && handle->events[evtype])
|
|
||||||
{
|
{
|
||||||
monitor_launch_script(mon,ptr,handle->script);
|
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
||||||
|
ptr->server->unique_name,
|
||||||
|
ptr->server->name,ptr->server->port,
|
||||||
|
mon_get_event_name(ptr));
|
||||||
|
if(handle->script && handle->events[evtype])
|
||||||
|
{
|
||||||
|
monitor_launch_script(mon,ptr,handle->script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@ -678,3 +681,32 @@ MONITOR_SERVERS *ptr;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static monitor_event_t mysql_events[] = {
|
||||||
|
MASTER_DOWN_EVENT,
|
||||||
|
MASTER_UP_EVENT,
|
||||||
|
SLAVE_DOWN_EVENT,
|
||||||
|
SLAVE_UP_EVENT,
|
||||||
|
SERVER_DOWN_EVENT,
|
||||||
|
SERVER_UP_EVENT,
|
||||||
|
LOST_MASTER_EVENT,
|
||||||
|
LOST_SLAVE_EVENT,
|
||||||
|
NEW_MASTER_EVENT,
|
||||||
|
NEW_SLAVE_EVENT,
|
||||||
|
MAX_MONITOR_EVENT
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Check if the MM monitor is monitoring this event type.
|
||||||
|
* @param event Event to check
|
||||||
|
* @return True if the event is monitored, false if it is not
|
||||||
|
* */
|
||||||
|
bool isMySQLEvent(monitor_event_t event)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0;mysql_events[i] != MAX_MONITOR_EVENT;i++)
|
||||||
|
{
|
||||||
|
if(event == mysql_events[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -80,7 +80,7 @@ static MONITOR_SERVERS *get_replication_tree(MONITOR *, int);
|
|||||||
static void set_master_heartbeat(MYSQL_MONITOR *, MONITOR_SERVERS *);
|
static void set_master_heartbeat(MYSQL_MONITOR *, MONITOR_SERVERS *);
|
||||||
static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *);
|
static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *);
|
||||||
static int add_slave_to_master(long *, int, long);
|
static int add_slave_to_master(long *, int, long);
|
||||||
|
bool isMySQLEvent(monitor_event_t event);
|
||||||
static MONITOR_OBJECT MyObject = {
|
static MONITOR_OBJECT MyObject = {
|
||||||
startMonitor,
|
startMonitor,
|
||||||
stopMonitor,
|
stopMonitor,
|
||||||
@ -693,15 +693,19 @@ int log_no_master = 1;
|
|||||||
while(ptr)
|
while(ptr)
|
||||||
{
|
{
|
||||||
/** Execute monitor script if a server state has changed */
|
/** Execute monitor script if a server state has changed */
|
||||||
if(mon_status_changed(ptr) && (evtype = mon_get_event_type(ptr)) != UNDEFINED_MONITOR_EVENT)
|
if(mon_status_changed(ptr))
|
||||||
{
|
{
|
||||||
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
evtype = mon_get_event_type(ptr);
|
||||||
ptr->server->unique_name,
|
if(isMySQLEvent(evtype))
|
||||||
ptr->server->name,ptr->server->port,
|
|
||||||
mon_get_event_name(ptr));
|
|
||||||
if(handle->script && handle->events[evtype])
|
|
||||||
{
|
{
|
||||||
monitor_launch_script(mon,ptr,handle->script);
|
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
||||||
|
ptr->server->unique_name,
|
||||||
|
ptr->server->name,ptr->server->port,
|
||||||
|
mon_get_event_name(ptr));
|
||||||
|
if(handle->script && handle->events[evtype])
|
||||||
|
{
|
||||||
|
monitor_launch_script(mon,ptr,handle->script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@ -1193,3 +1197,32 @@ static int add_slave_to_master(long *slaves_list, int list_size, long node_id) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static monitor_event_t mysql_events[] = {
|
||||||
|
MASTER_DOWN_EVENT,
|
||||||
|
MASTER_UP_EVENT,
|
||||||
|
SLAVE_DOWN_EVENT,
|
||||||
|
SLAVE_UP_EVENT,
|
||||||
|
SERVER_DOWN_EVENT,
|
||||||
|
SERVER_UP_EVENT,
|
||||||
|
LOST_MASTER_EVENT,
|
||||||
|
LOST_SLAVE_EVENT,
|
||||||
|
NEW_MASTER_EVENT,
|
||||||
|
NEW_SLAVE_EVENT,
|
||||||
|
MAX_MONITOR_EVENT
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Check if the MySQL monitor is monitoring this event type.
|
||||||
|
* @param event Event to check
|
||||||
|
* @return True if the event is monitored, false if it is not
|
||||||
|
* */
|
||||||
|
bool isMySQLEvent(monitor_event_t event)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0;mysql_events[i] != MAX_MONITOR_EVENT;i++)
|
||||||
|
{
|
||||||
|
if(event == mysql_events[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -52,6 +52,7 @@ MODULE_INFO info = {
|
|||||||
static void *startMonitor(void *,void*);
|
static void *startMonitor(void *,void*);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
|
bool isNdbEvent(monitor_event_t event);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = {
|
static MONITOR_OBJECT MyObject = {
|
||||||
startMonitor,
|
startMonitor,
|
||||||
@ -402,18 +403,57 @@ size_t nrounds = 0;
|
|||||||
while(ptr)
|
while(ptr)
|
||||||
{
|
{
|
||||||
/** Execute monitor script if a server state has changed */
|
/** Execute monitor script if a server state has changed */
|
||||||
if(mon_status_changed(ptr) && (evtype = mon_get_event_type(ptr)) != UNDEFINED_MONITOR_EVENT)
|
if(mon_status_changed(ptr))
|
||||||
{
|
{
|
||||||
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
evtype = mon_get_event_type(ptr);
|
||||||
ptr->server->unique_name,
|
if(isNdbEvent(evtype))
|
||||||
ptr->server->name,ptr->server->port,
|
|
||||||
mon_get_event_name(ptr));
|
|
||||||
if(handle->script && handle->events[evtype])
|
|
||||||
{
|
{
|
||||||
monitor_launch_script(mon,ptr,handle->script);
|
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
||||||
|
ptr->server->unique_name,
|
||||||
|
ptr->server->name,ptr->server->port,
|
||||||
|
mon_get_event_name(ptr));
|
||||||
|
if(handle->script && handle->events[evtype])
|
||||||
|
{
|
||||||
|
monitor_launch_script(mon,ptr,handle->script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static monitor_event_t ndb_events[] = {
|
||||||
|
MASTER_DOWN_EVENT,
|
||||||
|
MASTER_UP_EVENT,
|
||||||
|
SLAVE_DOWN_EVENT,
|
||||||
|
SLAVE_UP_EVENT,
|
||||||
|
SERVER_DOWN_EVENT,
|
||||||
|
SERVER_UP_EVENT,
|
||||||
|
NDB_UP_EVENT,
|
||||||
|
NDB_DOWN_EVENT,
|
||||||
|
LOST_MASTER_EVENT,
|
||||||
|
LOST_SLAVE_EVENT,
|
||||||
|
LOST_NDB_EVENT,
|
||||||
|
NEW_MASTER_EVENT,
|
||||||
|
NEW_SLAVE_EVENT,
|
||||||
|
NEW_NDB_EVENT,
|
||||||
|
MAX_MONITOR_EVENT
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the event type is one the ndbcustermonitor is interested in.
|
||||||
|
* @param event Event to check
|
||||||
|
* @return True if the event is monitored, false if it is not
|
||||||
|
*/
|
||||||
|
bool isNdbEvent(monitor_event_t event)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0;ndb_events[i] != MAX_MONITOR_EVENT;i++)
|
||||||
|
{
|
||||||
|
if(event == ndb_events[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user