Kill tcp connection when any backend gets healthy

Hello HAProxy experts,

I have postgres cluster of 2 nodes behind HAProxy, any of those two can be primary and replica (role is managed by separate system - stolon). I want to force HAProxy to reset tcp connection when primary postgres node comes back. I know there is on-marked-up shutdown-backup-sessions (HAProxy version 2.5.5 - Configuration Manual) which achieves resetting the connection but it has two requirements:

  • It shutdowns down sessions on server marked as backup.
  • It only shutdowns sessions when server which is marked up is not in backup state.

In my setup, since any of the two node can be primary or backup state (i.e. I don’t have static allocation of Node A to be primary and Node B to be replica) I am unable to achieve it by setting on-marked-up shutdown-backup-sessions

Is there any other way i can achieve resetting all backend connections when any of the backend node is marked up.

Any help or pointers will be much appreciated.

Regards,
Pradeep

Any pointers to this problem will be much appreciated.