Question
Can I get haproxy to close all connections to backup hosts when a primary host becomes available after being down?
Context
I am using HAproxy to do failover for pubsub.
The haproxy backend config looks something like this:
listen pubsub 0.0.0.0:1234
mode tcp
server primary primary.x.com:1234 weight 1 inter 500 rise 10 fall 5 check
server backup backup.x.com:1234 weight 1 inter 500 rise 10 fall 5 check backup
I make long lived connections for both the publish and the subscribe sides.
the problem is in the scenario that:
primary
goes downA
connects tobackup
and publishesB
connects tobackup
and subscribesprimary
is fixed and becomes alive againC
connects toprimary
and publishes butB
does not receive itD
connects toprimary
and subscribes but does not getA
's messages
The best solution to this problem that I can see is to have haproxy forcibly close all connections to backup hosts when a primary becomes available again.