I want to setup a HA postgres database. I setup master and slave database with synchronous streaming replication on different physical servers. When there is an error in the replication, the slave db triggers a script which switches the slave db to master db.
Both servers have an additional virtual ip address configured, in normal operation this interface is down on the slave db server. In case of a failure, the script will shutdown this interface on the master db server and start the corresponding one on the slave db server. Then the script executes some arp commands to let the LAN know that the IP address mapping has changed. When db clients reconnect they connect to the slave server which runs know as master on the same ip.
This works do far, but there are scenarios where it runs into trouble.
If I pull the network plug of the master machine, the failover mechanism will trigger. The slave db becomes master db on the same IP. However the script cannot shutdown the interface with the virtual IP on the (old) master, because the network is down. If I then put the network plug back in, there will be an ip address conflict on the virtual ip.
Are there concepts to also deal with such kind of situations?