HAProxy community

Using backup but I want disable persistence on failback

Hello

I’m looking to use Haproxy backup on a series of RabbitMQ clusters, I have it working, all except for when the primary cluster returns… On failback the connections still on the backup cluster persist (causing a split brain).

Is there away to force connections to close (on the backup) if there is a failback (to primary)?

Or even if there is a way to stop a failback (auto back to primary on recovery) occur unless the service is restarted?

I’ve been through lots of docs, but all I can find it stuff saying, ‘yes it will persist’. If I can’t get this functionality the solution is a no go.

Thank you

ok I just tried,
non-stick

tested and didn’t work

You’ll need to share the output of haproxy -vv and the entire configuration.

What you are looking for is probably on-marked-up for the backup server.

see below, if you need anything else just let me know

HA-Proxy version 1.5.18 2016/05/10
Copyright 2000-2016 Willy Tarreau <willy@haproxy.org>

Build options :
  TARGET  = linux2628
  CPU     = generic
  CC      = gcc
  CFLAGS  = -O2 -g -fno-strict-aliasing -DTCP_USER_TIMEOUT=18
  OPTIONS = USE_LINUX_TPROXY=1 USE_GETADDRINFO=1 USE_ZLIB=1 USE_REGPARM=1 USE_OPENSSL=1 USE_PCRE=1

Default settings :
  maxconn = 2000, bufsize = 16384, maxrewrite = 8192, maxpollevents = 200

Encrypted password support via crypt(3): yes
Built with zlib version : 1.2.7
Compression algorithms supported : identity, deflate, gzip
Built with OpenSSL version : OpenSSL 1.0.2k-fips  26 Jan 2017
Running on OpenSSL version : OpenSSL 1.0.2k-fips  26 Jan 2017
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports prefer-server-ciphers : yes
Built with PCRE version : 8.32 2012-11-30
PCRE library supports JIT : no (USE_PCRE_JIT not set)
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.






global
        daemon
        user haproxy
        group haproxy
 
defaults
        mode http

        maxconn 25000
        timeout connect 5s
        timeout client  120s
        timeout server  120s
 
listen stats
        bind 10.9.52.16:1978
        stats enable
        stats realm Haproxy\ Statistics\ RabbitMQ
        stats uri /
        stats refresh 5s
 
 
# RabbitMQ
listen rabbit
        bind 10.9.52.16:5672 v4v6
        balance roundrobin
        mode tcp
        option tcp-check
        option allbackups

 
        server rabbit-0  10.9.52.31:5672    check inter 2000 rise 2 fall 3 maxconn 5000
        server rabbit-1  10.9.52.32:5672    check inter 2000 rise 2 fall 3 maxconn 5000 
        server rabbit-2  10.9.52.33:5672    check inter 2000 rise 2 fall 3 maxconn 5000

        server rabbit-3  137.237.136.228:5672  backup check inter 2000 rise 2 fall 3 maxconn 5000 non-stick
        server rabbit-4  137.237.136.229:5672  backup check inter 2000 rise 2 fall 3 maxconn 5000 non-stick
        server rabbit-5  137.237.138.23:5672   backup check inter 2000 rise 2 fall 3 maxconn 5000 non-stick

on-marked-up shutdown-backup-sessions on the primary servers should work just fine in this case.

1 Like

I just tested it out, and it worked! THANK YOU @lukastribus

Here is my new config:

global
        daemon
        user haproxy
        group haproxy

 defaults
        mode http

        maxconn 25000
        timeout connect 5s
        timeout client  120s
        timeout server  120s
 
listen stats
        bind 10.9.52.16:1978
        stats enable
        stats realm Haproxy\ Statistics\ RabbitMQ
        stats uri /
        stats refresh 5s
 
# RabbitMQ
listen rabbit
        bind 10.9.52.16:5672 v4v6
        balance roundrobin
        mode tcp
        option tcp-check
        option allbackups
 
        server rabbit-0  10.9.52.31:5672    check inter 2000 rise 2 fall 3 maxconn 5000 on-marked-up shutdown-backup-sessions
        server rabbit-1  10.9.52.32:5672    check inter 2000 rise 2 fall 3 maxconn 5000 on-marked-up shutdown-backup-sessions
        server rabbit-2  10.9.52.33:5672    check inter 2000 rise 2 fall 3 maxconn 5000 on-marked-up shutdown-backup-sessions

        server rabbit-3  137.237.136.228:5672  backup check inter 2000 rise 2 fall 3 maxconn 5000 
        server rabbit-4  137.237.136.229:5672  backup check inter 2000 rise 2 fall 3 maxconn 5000 
        server rabbit-5  137.237.138.23:5672   backup check inter 2000 rise 2 fall 3 maxconn 5000