Removed restrictions on monitor timeouts
The monitor timeouts can now be larger than the monitor interval. This will allow the combination of low monitoring intervals and large network timeouts. If a network experiences some periodic lag, it is desirable to allow large timeout values.
This commit is contained in:
parent
a947b33769
commit
fec1ebe925
@ -2584,19 +2584,31 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
|
||||
char *connect_timeout = config_get_value(obj->parameters, "backend_connect_timeout");
|
||||
if (connect_timeout)
|
||||
{
|
||||
monitorSetNetworkTimeout(obj->element, MONITOR_CONNECT_TIMEOUT, atoi(connect_timeout));
|
||||
if (!monitorSetNetworkTimeout(obj->element, MONITOR_CONNECT_TIMEOUT, atoi(connect_timeout)))
|
||||
{
|
||||
MXS_ERROR("Failed to set backend_connect_timeout");
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
char *read_timeout = config_get_value(obj->parameters, "backend_read_timeout");
|
||||
if (read_timeout)
|
||||
{
|
||||
monitorSetNetworkTimeout(obj->element, MONITOR_READ_TIMEOUT, atoi(read_timeout));
|
||||
if (!monitorSetNetworkTimeout(obj->element, MONITOR_READ_TIMEOUT, atoi(read_timeout)))
|
||||
{
|
||||
MXS_ERROR("Failed to set backend_read_timeout");
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
char *write_timeout = config_get_value(obj->parameters, "backend_write_timeout");
|
||||
if (write_timeout)
|
||||
{
|
||||
monitorSetNetworkTimeout(obj->element, MONITOR_WRITE_TIMEOUT, atoi(write_timeout));
|
||||
if (!monitorSetNetworkTimeout(obj->element, MONITOR_WRITE_TIMEOUT, atoi(write_timeout)))
|
||||
{
|
||||
MXS_ERROR("Failed to set backend_write_timeout");
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the servers to monitor */
|
||||
|
@ -411,60 +411,39 @@ monitorSetInterval(MONITOR *mon, unsigned long interval)
|
||||
* @param type The timeout handling type
|
||||
* @param value The timeout to set
|
||||
*/
|
||||
void
|
||||
monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
|
||||
bool
|
||||
monitorSetNetworkTimeout(MONITOR *mon, int type, int value)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
int max_timeout = (int)(mon->interval/1000);
|
||||
int new_timeout = max_timeout -1;
|
||||
|
||||
if (new_timeout <= 0)
|
||||
if (value > 0)
|
||||
{
|
||||
new_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
switch (type)
|
||||
{
|
||||
case MONITOR_CONNECT_TIMEOUT:
|
||||
mon->connect_timeout = value;
|
||||
break;
|
||||
|
||||
case MONITOR_READ_TIMEOUT:
|
||||
mon->read_timeout = value;
|
||||
break;
|
||||
|
||||
case MONITOR_WRITE_TIMEOUT:
|
||||
mon->write_timeout = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_ERROR("Monitor setNetworkTimeout received an unsupported action type %i", type);
|
||||
rval = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case MONITOR_CONNECT_TIMEOUT:
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->connect_timeout, &value, sizeof(int));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->connect_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Connect Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
}
|
||||
break;
|
||||
|
||||
case MONITOR_READ_TIMEOUT:
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->read_timeout, &value, sizeof(int));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->read_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Read Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
}
|
||||
break;
|
||||
|
||||
case MONITOR_WRITE_TIMEOUT:
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->write_timeout, &value, sizeof(int));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->write_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Write Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MXS_ERROR("Monitor setNetworkTimeout received an unsupported action type %i", type);
|
||||
break;
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Negative value for monitor timeout.");
|
||||
rval = false;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +211,7 @@ extern void monitorShowAll(DCB *);
|
||||
extern void monitorShow(DCB *, MONITOR *);
|
||||
extern void monitorList(DCB *);
|
||||
extern void monitorSetInterval (MONITOR *, unsigned long);
|
||||
extern void monitorSetNetworkTimeout(MONITOR *, int, int);
|
||||
extern bool monitorSetNetworkTimeout(MONITOR *, int, int);
|
||||
extern RESULTSET *monitorGetList();
|
||||
bool check_monitor_permissions(MONITOR* monitor);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user