Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do hangups only after server states have been updated
The hangup code was refactored into a common function which should only be
used after the server states have been updated. This will remove erroneus
connections to already failed servers.
  • Loading branch information
markus456 committed Nov 9, 2016
1 parent b12a87e commit 7ef8b18
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
13 changes: 13 additions & 0 deletions server/core/monitor.c
Expand Up @@ -1055,3 +1055,16 @@ void mon_log_state_change(MONITOR_SERVERS *ptr)
free(prev);
free(next);
}

void mon_hangup_failed_servers(MONITOR *monitor)
{
for (MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
{
if (mon_status_changed(ptr) &&
(!(SERVER_IS_RUNNING(ptr->server)) ||
!(SERVER_IS_IN_CLUSTER(ptr->server))))
{
dcb_hangup_foreach(ptr->server);
}
}
}
9 changes: 9 additions & 0 deletions server/include/monitor.h
Expand Up @@ -222,4 +222,13 @@ connect_result_t mon_connect_to_db(MONITOR* mon, MONITOR_SERVERS *database);
void mon_log_connect_error(MONITOR_SERVERS* database, connect_result_t rval);
void mon_log_state_change(MONITOR_SERVERS *ptr);

/**
* @brief Hangup connections to failed servers
*
* Injects hangup events for DCB that are connected to servers that are down.
*
* @param monitor Monitor object
*/
void mon_hangup_failed_servers(MONITOR *monitor);

#endif
9 changes: 2 additions & 7 deletions server/modules/monitor/galeramon.c
Expand Up @@ -538,16 +538,9 @@ monitorMain(void *arg)
STRSRVSTATUS(ptr->server));
}

if (!(SERVER_IS_RUNNING(ptr->server)) ||
!(SERVER_IS_IN_CLUSTER(ptr->server)))
{
dcb_hangup_foreach(ptr->server);
}

if (SERVER_IS_DOWN(ptr->server))
{
/** Increase this server'e error count */
dcb_hangup_foreach(ptr->server);
ptr->mon_err_count += 1;

}
Expand Down Expand Up @@ -653,6 +646,8 @@ monitorMain(void *arg)
}
ptr = ptr->next;
}

mon_hangup_failed_servers(mon);
}
}

Expand Down
11 changes: 2 additions & 9 deletions server/modules/monitor/mmmon.c
Expand Up @@ -599,15 +599,6 @@ monitorMain(void *arg)
/* monitor current node */
monitorDatabase(mon, ptr);

if (mon_status_changed(ptr))
{
if (!(SERVER_IS_RUNNING(ptr->server)) ||
!(SERVER_IS_IN_CLUSTER(ptr->server)))
{
dcb_hangup_foreach(ptr->server);
}
}

if (mon_status_changed(ptr) ||
mon_print_fail_status(ptr))
{
Expand Down Expand Up @@ -679,6 +670,8 @@ monitorMain(void *arg)
}
ptr = ptr->next;
}

mon_hangup_failed_servers(mon);
}
}

Expand Down
18 changes: 2 additions & 16 deletions server/modules/monitor/mysql_mon.c
Expand Up @@ -860,22 +860,6 @@ monitorMain(void *arg)
ptr->server->name,
ptr->server->port);
}
/**
* Here we say: If the server's state changed
* so that it isn't running or some other way
* lost cluster membership, call call-back function
* of every DCB for which such callback was
* registered for this kind of issue (DCB_REASON_...)
*/
if (!(SERVER_IS_RUNNING(ptr->server)) ||
!(SERVER_IS_IN_CLUSTER(ptr->server)))
{
dcb_hangup_foreach(ptr->server);
}




}

if (mon_status_changed(ptr))
Expand Down Expand Up @@ -1090,6 +1074,8 @@ monitorMain(void *arg)
ptr = ptr->next;
}
}

mon_hangup_failed_servers(mon);
} /*< while (1) */
}

Expand Down
2 changes: 2 additions & 0 deletions server/modules/monitor/ndbclustermon.c
Expand Up @@ -447,6 +447,8 @@ monitorMain(void *arg)
}
ptr = ptr->next;
}

mon_hangup_failed_servers(mon);
}
}

Expand Down

0 comments on commit 7ef8b18

Please sign in to comment.