summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-04-17 19:13:42 -0700
committerdormando <dormando@rydia.net>2023-04-17 19:13:42 -0700
commit6a27618a0b2112b6f773d82887cff5c5b55f6dd5 (patch)
treef9a828fb17cb52cdcd906d41991fb07caf3f9e90
parent375869286af2c11137b050f80a45e4b4852a2723 (diff)
downloadmemcached-6a27618a0b2112b6f773d82887cff5c5b55f6dd5.tar.gz
proxy: use connect timeout during retries
The connect timeout is supposed to be applied to TCP connect() calls. The "retry timeout" is a poorly named variable for how long to wait before retrying a backend that is marked as bad. The retry timeout was accidentally being applied in cases where connect() was being called when retrying broken connections. This now uses the appropriate timeouts.
-rw-r--r--proxy_network.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/proxy_network.c b/proxy_network.c
index a764187..c95eb89 100644
--- a/proxy_network.c
+++ b/proxy_network.c
@@ -704,7 +704,7 @@ static void _backend_reconnect(mcp_backend_t *be) {
static void proxy_backend_retry_handler(const int fd, const short which, void *arg) {
mcp_backend_t *be = arg;
assert(which & EV_TIMEOUT);
- struct timeval tmp_time = be->tunables.retry;
+ struct timeval tmp_time = be->tunables.connect;
_backend_reconnect(be);
_set_main_event(be, be->event_thread->base, EV_WRITE, &tmp_time, proxy_beconn_handler);
}
@@ -714,8 +714,8 @@ static void proxy_backend_retry_handler(const int fd, const short which, void *a
// TODO (v2): extra counter for "backend connect tries" so it's still possible
// to see dead backends exist
static void _backend_failed(mcp_backend_t *be) {
- struct timeval tmp_time = be->tunables.retry;
if (++be->failed_count > be->tunables.backend_failure_limit) {
+ struct timeval tmp_time = be->tunables.retry;
if (!be->bad) {
P_DEBUG("%s: marking backend as bad\n", __func__);
STAT_INCR(be->event_thread->ctx, backend_marked_bad, 1);
@@ -724,6 +724,7 @@ static void _backend_failed(mcp_backend_t *be) {
be->bad = true;
_set_main_event(be, be->event_thread->base, EV_TIMEOUT, &tmp_time, proxy_backend_retry_handler);
} else {
+ struct timeval tmp_time = be->tunables.connect;
STAT_INCR(be->event_thread->ctx, backend_failed, 1);
_backend_reconnect(be);
_set_main_event(be, be->event_thread->base, EV_WRITE, &tmp_time, proxy_beconn_handler);