I have 3 servers setup: 1 primary, 2 backups. I used the following configuration:
backend pg_production_backend
option pgsql-check user pg_user
server primary pghost.primary:5432 check on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions
server secondary pghost.secondary:5432 check backup on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions
server tertiary pghost.tertiary:5432 check backup on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions
It works correctly when primary goes down, and connections will go to the first available backup; and connections return to primary when it comes back on.
The problem occurs when primary is down, and secondary is down. Connections will goto tertiary; when secondary comes back online; the connected clients remained on tertiary, and new connections go to secondary.
How to force all connections only goto tertiary or secondary while primary is still down?