hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.12k stars 115 forks source link

Can pg_auto_failover perform failback? #785

Closed gordonjb closed 3 years ago

gordonjb commented 3 years ago

In a scenario where failover occurs from primary to secondary, is it possible to set up pg_autofailover such that when the old primary is available again, it will fail back to the primary? From what I read, candidate_priority would only be taken into account during a failover

nenominal commented 3 years ago

I'm interested in this as well

DimCitus commented 3 years ago

Hi @gordonjb and @nenominal.

In PostgreSQL (and RDBMS) world a failover can't be transparent. Even when done without data loss, applications still need to reconnect to the new primary, and connections to Postgres are stateful because of session level objects that SQL allows you to create (prepared statements, temporary tables, cursors, etc).

In short that would be a very bad idea. Please make it so that your primary and secondary nodes are all the same and that you don't have to care about which one is currently playing which role. Naming conventions go a long way, that's why we have node1 and node2 rather than other names.