diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 2f8613dbe..14962a7d1 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -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 diff --git a/include/maxscale/service.h b/include/maxscale/service.h index 2550176ce..7bc75ce04 100644 --- a/include/maxscale/service.h +++ b/include/maxscale/service.h @@ -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 diff --git a/server/core/config.c b/server/core/config.c index 96046704d..c8501a668 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -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) { diff --git a/server/core/maxscale/service.h b/server/core/maxscale/service.h index 408cfc222..f8288e2bb 100644 --- a/server/core/maxscale/service.h +++ b/server/core/maxscale/service.h @@ -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 */ diff --git a/server/core/service.c b/server/core/service.c index c51677baa..5851ab4ed 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -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 *