Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: fixed fail_timeout and max_fails > 1.

Maxim Dounin
May 21, 2013 02:54PM
details: http://hg.nginx.org/nginx/rev/1d68b502088c
branches:
changeset: 5220:1d68b502088c
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue May 21 21:47:50 2013 +0400
description:
Upstream: fixed fail_timeout and max_fails > 1.

Due to peer->checked always set since rev. c90801720a0c (1.3.0)
by round-robin and least_conn balancers (ip_hash not affected),
the code in ngx_http_upstream_free_round_robin_peer() function
incorrectly reset peer->fails too often.

Reported by Dmitry Popov,
http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003720.html

diffstat:

src/http/modules/ngx_http_upstream_least_conn_module.c | 5 ++++-
src/http/ngx_http_upstream_round_robin.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)

diffs (30 lines):

diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
@@ -282,7 +282,10 @@ ngx_http_upstream_get_least_conn_peer(ng
}

best->current_weight -= total;
- best->checked = now;
+
+ if (now - best->checked > best->fail_timeout) {
+ best->checked = now;
+ }

pc->sockaddr = best->sockaddr;
pc->socklen = best->socklen;
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -523,7 +523,10 @@ ngx_http_upstream_get_peer(ngx_http_upst
rrp->tried[n] |= m;

best->current_weight -= total;
- best->checked = now;
+
+ if (now - best->checked > best->fail_timeout) {
+ best->checked = now;
+ }

return best;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Upstream: fixed fail_timeout and max_fails > 1.

Maxim Dounin 848 May 21, 2013 02:54PM



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

Online Users

Guests: 160
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