MXS-1198: Add configurable listener retry interval
The maximum listener retry interval is now configurable.
This commit is contained in:
parent
dd94374057
commit
1a8ff4b813
@ -886,6 +886,18 @@ Example:
|
||||
max_connections=100
|
||||
```
|
||||
|
||||
#### `max_retry_interval`
|
||||
|
||||
Configure the maximum interval between consecutive attempts to bind to an
|
||||
interface. The default value for this parameter is 3600 seconds. This
|
||||
parameter was introduced in MaxScale 2.2.0.
|
||||
|
||||
When a listener fails to bind to the interface it is assigned to, it will
|
||||
attempt to bind to the interface again after 10 seconds. If the attempt fails,
|
||||
the interval is incremented by 10 seconds and the next attempt will be in 20
|
||||
seconds. The interval is incremented until the value of `max_retry_interval` is
|
||||
reached at which point the listener attempts to bind to the interface every
|
||||
`max_retry_interval` seconds.
|
||||
|
||||
### Server
|
||||
|
||||
|
@ -151,6 +151,7 @@ typedef struct service
|
||||
bool retry_start; /**< If starting of the service should be retried later */
|
||||
bool log_auth_warnings; /**< Log authentication failures and warnings */
|
||||
uint64_t capabilities; /**< The capabilities of the service. */
|
||||
int max_retry_interval; /**< Maximum retry interval */
|
||||
} SERVICE;
|
||||
|
||||
typedef enum count_spec_t
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user