]> git.kaiwu.me - nginx.git/commitdiff
Upstream: fixed ip_hash rebalancing with the "down" flag.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 14 May 2012 09:58:07 +0000 (09:58 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 14 May 2012 09:58:07 +0000 (09:58 +0000)
Due to weight being set to 0 for down peers, order of peers after sorting
wasn't the same as without the "down" flag (with down peers at the end),
resulting in client rebalancing for clients on other servers.  The only
rebalancing which should happen after adding "down" to a server is one
for clients on the server.

The problem was introduced in r1377 (which fixed endless loop by setting
weight to 0 for down servers).  The loop is no longer possible with new
smooth algorithm, so preserving original weight is safe.

src/http/ngx_http_upstream_round_robin.c

index 6afe8bd71c809b3fcffcd0fb4662ab7734fd5520..214de7b74fce5b383b1b1d89ebf7e7f29204da23 100644 (file)
@@ -80,8 +80,8 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
                 peers->peer[n].max_fails = server[i].max_fails;
                 peers->peer[n].fail_timeout = server[i].fail_timeout;
                 peers->peer[n].down = server[i].down;
-                peers->peer[n].weight = server[i].down ? 0 : server[i].weight;
-                peers->peer[n].effective_weight = peers->peer[n].weight;
+                peers->peer[n].weight = server[i].weight;
+                peers->peer[n].effective_weight = server[i].weight;
                 peers->peer[n].current_weight = 0;
                 n++;
             }