]> git.kaiwu.me - haproxy.git/commit
[BUG] url_param hash may return a down server
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Mar 2010 05:22:16 +0000 (06:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Mar 2010 05:22:16 +0000 (06:22 +0100)
commit4256463b5a207888276e69e84f011b1ed53d2acd
tree065257770b5c727d1d97eab9a503c98f204731b0
parent6a8573ef6808abe454a68bf1527c119c4b840e5f
[BUG] url_param hash may return a down server

Jozef Hovan reported a bug sometimes causing a down server to be
used in url_param hashing mode.

This happens if the following conditions are met :
  - the backend contains more than one server with at least two
    of different weights
  - all servers but one are down
  - the server which is not down has a weight which does not divide
    all the other ones

Example: 3 servers with 20,20,10, the first one remains up.

The problem is caused by an optimisation in recalc_server_map()
which only fills the first map slot when only one server is up,
because all LB algorithms are optimized to use entry zero when
only one server is up... All but url_param. When doing the modulus,
we can return a position which is greater than zero and use an
entry which still refers to a server which has since been stopped.

One solution could be to optimize the url_param algo to proceed
as the other ones, but the fact that was wrong implies that we
can repeat the same bug later. So let's first correctly initialize
the map in order to avoid that trap.
src/lb_map.c