Proposal: Native High Availability and Automatic Failover in PostgreSQL

Started by Ale Rox7 months ago4 messages
#1Ale Rox
gitroxale@gmail.com

Dear all,

I've been using PostgreSQL for a long time and consider it a solid and
reliable database. However, I believe there is room for improvement in the
area of high availability and automatic failover, inspired by features
already available in MongoDB.

Specifically, it would be extremely useful to have:

- A built-in mechanism for automatic replication and failover, fully
integrated into PostgreSQL, without relying on external tools like Patroni;
- The ability to add new nodes to the cluster with automatic replication
configuration;
- Automatic failover behavior when a node goes down, allowing the cluster
to continue operating, and resynchronizing the node automatically when it
comes back online;
- A JDBC driver (and ideally other drivers as well) that accepts a list of
nodes in the connection string and can automatically detect the current
primary node for write operations — similar to how MongoDB drivers handle
replica sets.

The goal would be to have a single, fully integrated solution for high
availability, without needing to assemble multiple external components.
This would make PostgreSQL significantly easier to manage and more
competitive in environments where reliability and ease of use are key
requirements.

Are there any plans to introduce such functionality in the core PostgreSQL
project in the future?

Thank you for your attention and for the great work you do!

Best regards,
Rox Ale

#2wenhui qiu
qiuwenhuifx@gmail.com
In reply to: Ale Rox (#1)
Re: Proposal: Native High Availability and Automatic Failover in PostgreSQL

HI Ale Rox
I've been thinking like you for a long time, But it's not so easy to
realise this, there are more oppositions than approvals,You can search for
this title (Re: Built-in Raft replication)

On Wed, Jun 25, 2025 at 3:26 PM Ale Rox <gitroxale@gmail.com> wrote:

Show quoted text

Dear all,

I've been using PostgreSQL for a long time and consider it a solid and
reliable database. However, I believe there is room for improvement in the
area of high availability and automatic failover, inspired by features
already available in MongoDB.

Specifically, it would be extremely useful to have:

- A built-in mechanism for automatic replication and failover, fully
integrated into PostgreSQL, without relying on external tools like Patroni;
- The ability to add new nodes to the cluster with automatic replication
configuration;
- Automatic failover behavior when a node goes down, allowing the cluster
to continue operating, and resynchronizing the node automatically when it
comes back online;
- A JDBC driver (and ideally other drivers as well) that accepts a list of
nodes in the connection string and can automatically detect the current
primary node for write operations — similar to how MongoDB drivers handle
replica sets.

The goal would be to have a single, fully integrated solution for high
availability, without needing to assemble multiple external components.
This would make PostgreSQL significantly easier to manage and more
competitive in environments where reliability and ease of use are key
requirements.

Are there any plans to introduce such functionality in the core PostgreSQL
project in the future?

Thank you for your attention and for the great work you do!

Best regards,
Rox Ale

#3Greg Sabino Mullane
htamfids@gmail.com
In reply to: Ale Rox (#1)
Re: Proposal: Native High Availability and Automatic Failover in PostgreSQL

On Wed, Jun 25, 2025 at 3:26 AM Ale Rox <gitroxale@gmail.com> wrote:

Specifically, it would be extremely useful to have:

(snip wishlist)

Are there any plans to introduce such functionality in the core
PostgreSQL project in the future?

Getting failover to work, and work CORRECTLY[1]MongoDB does not have a good rep in this area, is an extremely
complicated task, fraught with tons of complicated edge cases and risks. It
may arrive "in core" someday, but it's going to be a very long road. I
would suggest starting on one of your bullets. Pick as small of a feature
as you can, then expand on its use case and all the specific items it would
need to do. Look at Patroni (current best-in-class failover system for
Postgres) and see how it does it, then try to map how Postgres itself could
do the same.

[1]: MongoDB does not have a good rep in this area

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

#4Greg Sabino Mullane
htamfids@gmail.com
In reply to: Ale Rox (#1)
Re: Proposal: Native High Availability and Automatic Failover in PostgreSQL

On Wed, Jun 25, 2025 at 3:26 AM Ale Rox <gitroxale@gmail.com> wrote:

- A JDBC driver (and ideally other drivers as well) that accepts a list of
nodes in the connection string and can automatically detect the current
primary node for write operations — similar to how MongoDB drivers handle
replica sets.

This one could be done with the help of one of my outstanding patches:

/messages/by-id/CAKAnmm+T-CEDLmRezWfH-7ZEsFfD_kU2KY1TgB288K+wprB_4Q@mail.gmail.com

--
Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support