Rearrange the logic in do_failover() for further improvements.

Specially, make this a more coordinated process by making all
nodes waiting for the others before going to the next step.

This is one step further in following Andres Freund advices
but there is still a lot to do in order to complete that,
specially it could be needed to add more fields to repl_nodes
and to the shm area.
Make repmgrd survive to the failover

To do this it needs to reconnect to the new master
Rework algorithm to coordinate voting

Make this by waiting for all nodes to finish a step, before starting
a new one. So everyone starts promoting or following in a coordinated
fashion.
Also make a few fixes.