[nginx] Upstream: report to error_log when max_fails is reached.

Ruslan Ermilov ru at nginx.com
Wed May 20 19:44:49 UTC 2015


details:   http://hg.nginx.org/nginx/rev/cca856715722
branches:  
changeset: 6154:cca856715722
user:      Ruslan Ermilov <ru at nginx.com>
date:      Wed May 20 22:44:00 2015 +0300
description:
Upstream: report to error_log when max_fails is reached.

This can be useful to understand why "no live upstreams" happens,
in particular.

diffstat:

 src/http/ngx_http_upstream_round_robin.c     |  5 +++++
 src/stream/ngx_stream_upstream_round_robin.c |  5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r 4f6efabcb09b -r cca856715722 src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c	Wed May 20 15:51:56 2015 +0300
+++ b/src/http/ngx_http_upstream_round_robin.c	Wed May 20 22:44:00 2015 +0300
@@ -622,6 +622,11 @@ ngx_http_upstream_free_round_robin_peer(
 
         if (peer->max_fails) {
             peer->effective_weight -= peer->weight / peer->max_fails;
+
+            if (peer->fails >= peer->max_fails) {
+                ngx_log_error(NGX_LOG_WARN, pc->log, 0,
+                              "upstream server temporarily disabled");
+            }
         }
 
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
diff -r 4f6efabcb09b -r cca856715722 src/stream/ngx_stream_upstream_round_robin.c
--- a/src/stream/ngx_stream_upstream_round_robin.c	Wed May 20 15:51:56 2015 +0300
+++ b/src/stream/ngx_stream_upstream_round_robin.c	Wed May 20 22:44:00 2015 +0300
@@ -495,6 +495,11 @@ ngx_stream_upstream_free_round_robin_pee
 
         if (peer->max_fails) {
             peer->effective_weight -= peer->weight / peer->max_fails;
+
+            if (peer->fails >= peer->max_fails) {
+                ngx_log_error(NGX_LOG_WARN, pc->log, 0,
+                              "upstream server temporarily disabled");
+            }
         }
 
         ngx_log_debug2(NGX_LOG_DEBUG_STREAM, pc->log, 0,



More information about the nginx-devel mailing list