I am using HAProxy for load balancing with master-slave replication (1 master and 2 slaves). When master goes down i am utilizing mysql utilities to provide HA.
Based on my observation when master went down the connections from HAProxy are hitting the new master(slave 1). When the old master is brought back alive, the connections are hitting the old master, but the old master is not synchronized to the current data which leads to outage. Can anyone please provide me HAProxy configuration, to make the connections hit only to which ever server is in the master position.
my current haproxy conig is like mentioned below:
backend
server 1 master 0.0.0.0:3306 check
server 2 slave1 0.0.0.1:3306 check backup
server 3 slave2 0.0.0.2:3306 check backup
due to this configuration if master server is down connection go to the next available server, but if the master is up the connection are hitting back to the master.