MXS-2329 Use durations with query_retry_timeout

Also change auth_[connect|read|write]_timeout to be time_t.
This commit is contained in:
Johan Wikman
2019-04-26 17:00:45 +03:00
parent 92cc31f0c0
commit 3055e49f5a
4 changed files with 30 additions and 31 deletions

View File

@ -401,6 +401,12 @@ seconds.
An interrupted query is retried for either the configured amount of attempts or An interrupted query is retried for either the configured amount of attempts or
until the configured timeout is reached. until the configured timeout is reached.
The value is specified as documented [here](#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second.
#### `passive` #### `passive`
Controls whether MaxScale is a passive node in a cluster of multiple MaxScale Controls whether MaxScale is a passive node in a cluster of multiple MaxScale

View File

@ -477,10 +477,10 @@ struct MXS_CONFIG
unsigned int pollsleep; /**< Wait time in blocking polls */ unsigned int pollsleep; /**< Wait time in blocking polls */
int syslog; /**< Log to syslog */ int syslog; /**< Log to syslog */
int maxlog; /**< Log to MaxScale's own logs */ int maxlog; /**< Log to MaxScale's own logs */
unsigned int auth_conn_timeout; /**< Connection timeout for the user time_t auth_conn_timeout; /**< Connection timeout for the user
* authentication */ * authentication */
unsigned int auth_read_timeout; /**< Read timeout for the user authentication */ time_t auth_read_timeout; /**< Read timeout for the user authentication */
unsigned int auth_write_timeout; /**< Write timeout for the user authentication */ time_t auth_write_timeout; /**< Write timeout for the user authentication */
bool skip_permission_checks; /**< Skip service and monitor permission checks */ bool skip_permission_checks; /**< Skip service and monitor permission checks */
int32_t passive; /**< True if MaxScale is in passive mode */ int32_t passive; /**< True if MaxScale is in passive mode */
int64_t promoted_at; /**< Time when this Maxscale instance was int64_t promoted_at; /**< Time when this Maxscale instance was

View File

@ -238,7 +238,7 @@ static pcre2_code* compile_regex_string(const char* regex_string,
uint32_t* output_ovector_size); uint32_t* output_ovector_size);
static bool duration_is_valid(const char* zValue, mxs::config::DurationUnit* pUnit); static bool duration_is_valid(const char* zValue, mxs::config::DurationUnit* pUnit);
static bool get_seconds(const char* zName, const char* zValue, std::chrono::seconds* pSeconds); static bool get_seconds(const char* zName, const char* zValue, std::chrono::seconds* pSeconds);
static bool get_seconds(const char* zName, const char* zValue, unsigned int* pSeconds); static bool get_seconds(const char* zName, const char* zValue, time_t* pSeconds);
int config_get_ifaddr(unsigned char* output); int config_get_ifaddr(unsigned char* output);
@ -2487,15 +2487,8 @@ static int handle_global_item(const char* name, const char* value)
} }
else if (strcmp(name, CN_QUERY_RETRY_TIMEOUT) == 0) else if (strcmp(name, CN_QUERY_RETRY_TIMEOUT) == 0)
{ {
char* endptr; if (!get_seconds(name, value, &gateway.query_retry_timeout))
int intval = strtol(value, &endptr, 0);
if (*endptr == '\0' && intval > 0)
{ {
gateway.query_retry_timeout = intval;
}
else
{
MXS_ERROR("Invalid timeout value for '%s': %s", CN_QUERY_RETRY_TIMEOUT, value);
return 0; return 0;
} }
} }
@ -4723,9 +4716,9 @@ static bool create_global_config(const char* filename)
} }
dprintf(file, "[maxscale]\n"); dprintf(file, "[maxscale]\n");
dprintf(file, "%s=%u\n", CN_AUTH_CONNECT_TIMEOUT, gateway.auth_conn_timeout); dprintf(file, "%s=%ld\n", CN_AUTH_CONNECT_TIMEOUT, gateway.auth_conn_timeout);
dprintf(file, "%s=%u\n", CN_AUTH_READ_TIMEOUT, gateway.auth_read_timeout); dprintf(file, "%s=%ld\n", CN_AUTH_READ_TIMEOUT, gateway.auth_read_timeout);
dprintf(file, "%s=%u\n", CN_AUTH_WRITE_TIMEOUT, gateway.auth_write_timeout); dprintf(file, "%s=%ld\n", CN_AUTH_WRITE_TIMEOUT, gateway.auth_write_timeout);
dprintf(file, "%s=%s\n", CN_ADMIN_AUTH, gateway.admin_auth ? "true" : "false"); dprintf(file, "%s=%s\n", CN_ADMIN_AUTH, gateway.admin_auth ? "true" : "false");
dprintf(file, "%s=%u\n", CN_PASSIVE, gateway.passive); dprintf(file, "%s=%u\n", CN_PASSIVE, gateway.passive);
@ -5128,7 +5121,7 @@ static bool get_seconds(const char* zName, const char* zValue, std::chrono::seco
return valid; return valid;
} }
static bool get_seconds(const char* zName, const char* zValue, unsigned int* pSeconds) static bool get_seconds(const char* zName, const char* zValue, time_t* pSeconds)
{ {
std::chrono::seconds seconds; std::chrono::seconds seconds;

View File

@ -838,14 +838,14 @@ bool runtime_alter_maxscale(const char* name, const char* value)
if (key == CN_AUTH_CONNECT_TIMEOUT) if (key == CN_AUTH_CONNECT_TIMEOUT)
{ {
int intval = get_positive_int(value); time_t timeout = get_positive_int(value);
if (intval) if (timeout)
{ {
MXS_NOTICE("Updated '%s' from %d to %d", MXS_NOTICE("Updated '%s' from %ld to %ld",
CN_AUTH_CONNECT_TIMEOUT, CN_AUTH_CONNECT_TIMEOUT,
cnf.auth_conn_timeout, cnf.auth_conn_timeout,
intval); timeout);
cnf.auth_conn_timeout = intval; cnf.auth_conn_timeout = timeout;
rval = true; rval = true;
} }
else else
@ -855,14 +855,14 @@ bool runtime_alter_maxscale(const char* name, const char* value)
} }
else if (key == CN_AUTH_READ_TIMEOUT) else if (key == CN_AUTH_READ_TIMEOUT)
{ {
int intval = get_positive_int(value); time_t timeout = get_positive_int(value);
if (intval) if (timeout)
{ {
MXS_NOTICE("Updated '%s' from %d to %d", MXS_NOTICE("Updated '%s' from %ld to %ld",
CN_AUTH_READ_TIMEOUT, CN_AUTH_READ_TIMEOUT,
cnf.auth_read_timeout, cnf.auth_read_timeout,
intval); timeout);
cnf.auth_read_timeout = intval; cnf.auth_read_timeout = timeout;
rval = true; rval = true;
} }
else else
@ -872,14 +872,14 @@ bool runtime_alter_maxscale(const char* name, const char* value)
} }
else if (key == CN_AUTH_WRITE_TIMEOUT) else if (key == CN_AUTH_WRITE_TIMEOUT)
{ {
int intval = get_positive_int(value); time_t timeout = get_positive_int(value);
if (intval) if (timeout)
{ {
MXS_NOTICE("Updated '%s' from %d to %d", MXS_NOTICE("Updated '%s' from %ld to %ld",
CN_AUTH_WRITE_TIMEOUT, CN_AUTH_WRITE_TIMEOUT,
cnf.auth_write_timeout, cnf.auth_write_timeout,
intval); timeout);
cnf.auth_write_timeout = intval; cnf.auth_write_timeout = timeout;
rval = true; rval = true;
} }
else else