summaryrefslogtreecommitdiff
path: root/proto_proxy.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-02-03 14:49:54 -0800
committerdormando <dormando@rydia.net>2022-02-04 13:56:25 -0800
commit245cf4c0f9d44e3891d12bc3dbf368a1b28e8627 (patch)
treee3fb746badf3e4accfb5da4925b032bfb268a922 /proto_proxy.c
parent3614f3cf495e1e2b25afde8d4e2e3c0c30bd0dac (diff)
downloadmemcached-245cf4c0f9d44e3891d12bc3dbf368a1b28e8627.tar.gz
proxy: counter for backend failures
think this ony counts failues related to the connect routine, and when a backend is considered dead. Looks like I was partway through deciding how to change that. I'm sure it's possible for something to fail in such a way that it connects, then immediately fails, which escapes this routine. Separate fix for that though.
Diffstat (limited to 'proto_proxy.c')
-rw-r--r--proto_proxy.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/proto_proxy.c b/proto_proxy.c
index f8bb504..5936f94 100644
--- a/proto_proxy.c
+++ b/proto_proxy.c
@@ -169,6 +169,8 @@ struct proxy_global_stats {
uint64_t backend_requests; // reqs sent to backends
uint64_t backend_responses; // responses received from backends
uint64_t backend_errors; // errors from backends
+ uint64_t backend_marked_bad; // backend set to autofail
+ uint64_t backend_failed; // an error caused a backend reset
};
struct proxy_tunables {
@@ -439,6 +441,8 @@ void proxy_stats(ADD_STAT add_stats, conn *c) {
APPEND_STAT("proxy_config_reloads", "%llu", (unsigned long long)ctx->global_stats.config_reloads);
APPEND_STAT("proxy_config_reload_fails", "%llu", (unsigned long long)ctx->global_stats.config_reload_fails);
APPEND_STAT("proxy_backend_total", "%llu", (unsigned long long)ctx->global_stats.backend_total);
+ APPEND_STAT("proxy_backend_marked_bad", "%llu", (unsigned long long)ctx->global_stats.backend_marked_bad);
+ APPEND_STAT("proxy_backend_failed", "%llu", (unsigned long long)ctx->global_stats.backend_failed);
STAT_UL(ctx);
}
@@ -1488,7 +1492,6 @@ static void proxy_backend_wrhandler_ur(void *udata, struct io_uring_cqe *cqe) {
int res = _flush_pending_write(be);
if (res == -1) {
_reset_bad_backend(be);
- // FIXME: backend_failed counter?
return;
}
@@ -2255,7 +2258,9 @@ static void _backend_failed(mcp_backend_t *be) {
P_DEBUG("%s: marking backend as bad\n", __func__);
be->bad = true;
_set_event(be, be->event_thread->base, EV_TIMEOUT, tmp_time, proxy_backend_retry_handler);
+ STAT_INCR(be->event_thread->ctx, backend_marked_bad, 1);
} else {
+ STAT_INCR(be->event_thread->ctx, backend_failed, 1);
_set_event(be, be->event_thread->base, EV_WRITE|EV_TIMEOUT, tmp_time, proxy_backend_handler);
}
}