
Thanks to pg_auto_failover there is an easy way to setup a couple of Postgres nodes with failover capabilities. Do you really need to ask for a production-grade environment just for this test?

That sounds like a DBA job now, and we just want to easily check your application connection string locally.
POSTGRES APP DEFAULT PASSWORD HOW TO
If you want to try out this multi-host connection string and test it with your application, well, you need to setup at least a primary Postgres node and one standby, and you need to know how to implement a Postgres failover. “In theory, theory and practice are the same thing… not in practice”. Testing environment: a 1-line docker command thanks to pg_auto_failoverĬonventional wisdom has this great quote about theory and practice: It might be that node1 is now down and can’t be reached anymore, or that node1 is already back online as a standby node: in either case your connection string that is using target_session_attrs=read-write is going to fail on node1, and keep trying, until one of the remaining nodes is found to provide a read-write session.

Now, given that multi-host connection string capability, you have a way to keep re-using the exact same connection string after a failover happened.
POSTGRES APP DEFAULT PASSWORD CODE
So, if you go back to thinking about your main scenario here: what happens to your application code when a failover happens in production? What you know already is that your connection to the database is lost during a failover. Handling a failover from the application perspective The next host on the HOST list will now be tried, in a loop, until you either find one that supports your target session attributes, or until all the hosts in the HOST list have been tried.

But it’s still useful to understand what happens to your application when a Postgres failover occurs. Now, if you’re running your app on top of a managed service with HA, you probably don’t need to worry about how to implement HA, as HA is managed by the service. Your application might be running on Postgres on-prem with HA configured-or in the cloud-or on a managed PostgreSQL service such as Azure Database for PostgreSQL.

In this post, you will learn what happens to your application code and connections when a Postgres failover is orchestrated. Application code has a super important role to play, too. That said, the server side of the stack is not the only thing that matters when implementing high availability. Having a Postgres service running with the expected data set is all-important and required for HA, of course. When those of us who work on Postgres High Availability explain how HA in Postgres works, we often focus on the server side of the stack.
