MXS-1198: Add configurable listener retry interval
The maximum listener retry interval is now configurable.
This commit is contained in:
@ -124,6 +124,7 @@ static const char *service_params[] =
|
||||
"passwd", // DEPRECATE: See config_get_password.
|
||||
"password",
|
||||
"enable_root_user",
|
||||
"max_retry_interval",
|
||||
"max_connections",
|
||||
"max_queued_connections",
|
||||
"queued_connection_timeout",
|
||||
@ -2561,6 +2562,24 @@ int create_new_service(CONFIG_CONTEXT *obj)
|
||||
serviceEnableRootUser(obj->element, config_truth_value(enable_root_user));
|
||||
}
|
||||
|
||||
char *max_retry_interval = config_get_value(obj->parameters, "max_retry_interval");
|
||||
|
||||
if (max_retry_interval)
|
||||
{
|
||||
char *endptr;
|
||||
long val = strtol(max_retry_interval, &endptr, 10);
|
||||
|
||||
if (val && *endptr == '\0')
|
||||
{
|
||||
service_set_retry_interval(obj->element, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Invalid value for 'max_retry_interval': %s", max_retry_interval);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
char *connection_timeout = config_get_value(obj->parameters, "connection_timeout");
|
||||
if (connection_timeout)
|
||||
{
|
||||
|
||||
@ -129,6 +129,14 @@ void service_update(SERVICE *service, char *router, char *user, char *auth);
|
||||
*/
|
||||
void service_add_parameters(SERVICE *service, const MXS_CONFIG_PARAMETER *param);
|
||||
|
||||
/**
|
||||
* @brief Set listener rebinding interval
|
||||
*
|
||||
* @param service Service to configure
|
||||
* @param value String value o
|
||||
*/
|
||||
void service_set_retry_interval(SERVICE *service, int value);
|
||||
|
||||
/**
|
||||
* Internal debugging diagnostics
|
||||
*/
|
||||
|
||||
@ -146,6 +146,7 @@ SERVICE* service_alloc(const char *name, const char *router)
|
||||
ss_dassert(module);
|
||||
|
||||
service->capabilities = module->module_capabilities;
|
||||
service->max_retry_interval = SERVICE_MAX_RETRY_INTERVAL;
|
||||
service->client_count = 0;
|
||||
service->n_dbref = 0;
|
||||
service->name = my_name;
|
||||
@ -405,7 +406,7 @@ int serviceStartAllPorts(SERVICE* service)
|
||||
service->stats.n_failed_starts++;
|
||||
char taskname[strlen(service->name) + strlen("_start_retry_") +
|
||||
(int) ceil(log10(INT_MAX)) + 1];
|
||||
int retry_after = MXS_MIN(service->stats.n_failed_starts * 10, SERVICE_MAX_RETRY_INTERVAL);
|
||||
int retry_after = MXS_MIN(service->stats.n_failed_starts * 10, service->max_retry_interval);
|
||||
snprintf(taskname, sizeof(taskname), "%s_start_retry_%d",
|
||||
service->name, service->stats.n_failed_starts);
|
||||
hktask_oneshot(taskname, service_internal_restart,
|
||||
@ -994,6 +995,7 @@ serviceClearRouterOptions(SERVICE *service)
|
||||
}
|
||||
spinlock_release(&service->spin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service user that is used to log in to the backebd servers
|
||||
* associated with this service.
|
||||
@ -1205,6 +1207,12 @@ void serviceSetRetryOnFailure(SERVICE *service, char* value)
|
||||
}
|
||||
}
|
||||
|
||||
void service_set_retry_interval(SERVICE *service, int value)
|
||||
{
|
||||
ss_dassert(value > 0);
|
||||
service->max_retry_interval = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filters used by the service
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user