Hello Artur,

On Tue, Sep 06, 2022 at 05:50:47PM +0200, Artur wrote:
> Hello !
> 
> I'm adding two servers s01 and s02 to the current config and setting the
> same cookie value as for existing s1 and s2.
> These cookies are here to permit sticky sessions.
> What may be the behaviour of haproxy in this situation ?

Haproxy will pick the first operating server using the requested cookie.
That's seldom used when an alternate paths to the same server is available,
but most commonly when using active and backup servers in fact.

> 'haproxy -c' on the configuration file does not show any warning or error.

That's expected because we must not emit warnings on valid configs that
cannot be expressed differently (otherwise users won't read warnings
anymore). However there's a diagnostic mode which already detects such
unusual setups and which will emit a few reports to help you spot such
cases:

> backend one
>         ...
>         option redispatch
>         balance roundrobin
>         server s1 10.100.0.93:2000 cookie s1
>         server s2 10.100.0.93:2001 cookie s2
>         server s01 10.100.3.101:2000 cookie s1
>         server s02 10.100.3.101:2001 cookie s2
>         option allbackups
>         server sb1 10.100.131.33:2000 cookie s1 backup
>         server sb2 10.100.131.33:2001 cookie s2 backup

  $ ./haproxy -dD -f foo.cfg
  (...)
  [DIAG]     (22717) : config : parsing [foo.cfg:7] : 'server s01' : same 
cookie value is set for a previous non-backup server in the same backend, it 
may break connection persistence
  [DIAG]     (22717) : config : parsing [foo.cfg:8] : 'server s02' : same 
cookie value is set for a previous non-backup server in the same backend, it 
may break connection persistence

The purpose of the diag really is to distinguish what's likely valid
and unlikely valid, compared to what's valid and not valid, thus it
will mostly help you spot typos or copy-paste errors.

Willy

Reply via email to