Welcome! Log In Create A New Profile

Advanced

Upstream: Count peer->fails if peers->single is 1

u5h
March 07, 2023 07:12PM
Hello.
The upstream peer status is always up when the upstream peer is single.
FYI: https://github.com/vozlt/nginx-module-vts/issues/262
The conventional upstream round robin hasn't count peer->fails anywhere
when it is peers->single is 1.
Thus we’d like to only count it, but not to judge that the peer is down.


# HG changeset patch
# User Yugo Horie <u5.horie@gmail.com>
# Date 1678105277 -32400
# Mon Mar 06 21:21:17 2023 +0900
# Node ID bd2cfa9541df90fa45883797cba56a26fc5f39c0
# Parent 2acb00b9b5fff8a97523b659af4377fc605abe6e
Upstream: Count peer->fails if peers->single is 1

The log based monitoring modules (e.g. nginx-module-vts)
can identify the upstream peer is up or down with
peer->fails even if it is the single upstream peer.

diff -r 2acb00b9b5ff -r bd2cfa9541df
src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c Thu Feb 23 20:50:03 2023
+0300
+++ b/src/http/ngx_http_upstream_round_robin.c Mon Mar 06 21:21:17 2023
+0900
@@ -551,7 +551,7 @@
continue;
}

- if (peer->max_fails
+ if (!rrp->peers->single && peer->max_fails
&& peer->fails >= peer->max_fails
&& now - peer->checked <= peer->fail_timeout)
{
@@ -618,6 +618,11 @@
if (rrp->peers->single) {

peer->conns--;
+ if (state & NGX_PEER_FAILED) {
+ peer->fails++;
+ } else {
+ peer->fails = 0;
+ }

ngx_http_upstream_rr_peer_unlock(rrp->peers, peer);
ngx_http_upstream_rr_peers_unlock(rrp->peers);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Upstream: Count peer->fails if peers->single is 1

u5h 277 March 07, 2023 07:12PM

Re: Upstream: Count peer->fails if peers->single is 1

Maxim Dounin 79 March 08, 2023 05:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 90
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready