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:
@ -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");
|
char *connect_timeout = config_get_value(obj->parameters, "backend_connect_timeout");
|
||||||
if (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");
|
char *read_timeout = config_get_value(obj->parameters, "backend_read_timeout");
|
||||||
if (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");
|
char *write_timeout = config_get_value(obj->parameters, "backend_write_timeout");
|
||||||
if (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 */
|
/* get the servers to monitor */
|
||||||
|
|||||||
@ -411,60 +411,39 @@ monitorSetInterval(MONITOR *mon, unsigned long interval)
|
|||||||
* @param type The timeout handling type
|
* @param type The timeout handling type
|
||||||
* @param value The timeout to set
|
* @param value The timeout to set
|
||||||
*/
|
*/
|
||||||
void
|
bool
|
||||||
monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
|
monitorSetNetworkTimeout(MONITOR *mon, int type, int value)
|
||||||
|
{
|
||||||
|
bool rval = true;
|
||||||
|
|
||||||
int max_timeout = (int)(mon->interval/1000);
|
if (value > 0)
|
||||||
int new_timeout = max_timeout -1;
|
{
|
||||||
|
switch (type)
|
||||||
if (new_timeout <= 0)
|
|
||||||
{
|
{
|
||||||
new_timeout = DEFAULT_CONNECT_TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case MONITOR_CONNECT_TIMEOUT:
|
case MONITOR_CONNECT_TIMEOUT:
|
||||||
if (value < max_timeout)
|
mon->connect_timeout = value;
|
||||||
{
|
|
||||||
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;
|
break;
|
||||||
|
|
||||||
case MONITOR_READ_TIMEOUT:
|
case MONITOR_READ_TIMEOUT:
|
||||||
if (value < max_timeout)
|
mon->read_timeout = value;
|
||||||
{
|
|
||||||
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;
|
break;
|
||||||
|
|
||||||
case MONITOR_WRITE_TIMEOUT:
|
case MONITOR_WRITE_TIMEOUT:
|
||||||
if (value < max_timeout)
|
mon->write_timeout = value;
|
||||||
{
|
break;
|
||||||
memcpy(&mon->write_timeout, &value, sizeof(int));
|
|
||||||
|
default:
|
||||||
|
MXS_ERROR("Monitor setNetworkTimeout received an unsupported action type %i", type);
|
||||||
|
rval = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy(&mon->write_timeout, &new_timeout, sizeof(int));
|
MXS_ERROR("Negative value for monitor timeout.");
|
||||||
MXS_WARNING("Monitor Write Timeout %i is greater than monitor interval ~%i seconds"
|
rval = false;
|
||||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MXS_ERROR("Monitor setNetworkTimeout received an unsupported action type %i", type);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -211,7 +211,7 @@ extern void monitorShowAll(DCB *);
|
|||||||
extern void monitorShow(DCB *, MONITOR *);
|
extern void monitorShow(DCB *, MONITOR *);
|
||||||
extern void monitorList(DCB *);
|
extern void monitorList(DCB *);
|
||||||
extern void monitorSetInterval (MONITOR *, unsigned long);
|
extern void monitorSetInterval (MONITOR *, unsigned long);
|
||||||
extern void monitorSetNetworkTimeout(MONITOR *, int, int);
|
extern bool monitorSetNetworkTimeout(MONITOR *, int, int);
|
||||||
extern RESULTSET *monitorGetList();
|
extern RESULTSET *monitorGetList();
|
||||||
bool check_monitor_permissions(MONITOR* monitor);
|
bool check_monitor_permissions(MONITOR* monitor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user