すべての記事

PostgreSQL high availability with Replication Manager: switchover, failover and rejoin in three topologies

Replication Manager started in 2015 as a failover tool for MariaDB and MySQL replication. Since release 3.1.43 it also monitors PostgreSQL clusters, and release 3.1.50, published tonight, is the first I would recommend to a PostgreSQL team for a real cluster. This post says what it does on PostgreSQL today, what is partial, what is not there, and how long a switchover and a failover take on our own cluster. No marketing table at the end: the coverage table is the honest one we use ourselves.

Three topologies, one monitor

A PostgreSQL cluster is a set of servers Replication Manager watches every two seconds: topology, replication lag, standby state, health, with the same alerts and the same state machine as a MariaDB cluster. Three shapes are supported:

  • Active-passive. One instance whose data volume follows it across the nodes; the orchestrator restarts it elsewhere when its node dies. No replica to manage, the simplest shape for a small database.
  • WAL streaming. A primary and one or more standbys seeded by pg_basebackup, replicating the write-ahead log. The classic PostgreSQL replication.
  • Logical replication. A publisher and subscribers on a publication. Useful across major versions, and for a switchover that takes seconds instead of a restart.

Nothing is borrowed from the MariaDB statements: the PostgreSQL path has its own switchover, failover and rejoin, written against pg_stat_replication, pg_rewind, pg_promote and the subscription catalog, and the tool checks every SQL function it owns on both engines before a release.

What a switchover and a failover cost

Measured on our preprod cluster, PostgreSQL 17, with sysbench traffic on, in October 2026:

Step WAL streaming Logical replication
Switchover 26 to 31 s: PostgreSQL cannot demote a running primary, so the old primary is restarted as a standby of the promoted one 2 to 3 s: the publisher is frozen read-only, the subscriber promoted, the old publisher subscribes
Failover 8 s: the most advanced standby is promoted, the others repointed 8 s: the subscriber drops its subscription and publishes
Rejoin of the former primary by pg_rewind, data kept; a full copy when it cannot re-subscribes without a copy; writes taken after a failover are reported, not reconciled
Routing HAProxy leader and reader backends repointed, as for MariaDB the same

The role change of a WAL streaming server is armed by the jobs sidecar that runs next to each PostgreSQL instance and applied at its next start, so it works on any orchestrator able to restart the server: OpenSVC and Kubernetes today, your own scripts if you prefer, since every action Replication Manager takes can be replaced by a script of yours.

Backups, WAL archive and reseed

  • Logical backups with pg_dumpall, physical backups with pg_basebackup, scheduled, with progress, kept locally and pushed to the archives you configure (restic, plakar, Proxmox Backup Server). The sidecar asks Replication Manager for its tasks and streams the result back through the API: nothing of the tool is written in your database, nothing of it ends up in your backups.
  • WAL archive. With the transaction log copy on, each completed WAL segment is archived from the server and shipped to Replication Manager, kept from one hour before the oldest physical backup. A point-in-time restore from it is planned, not shipped.
  • Restore and reseed. A physical restore rebuilds a server from a pg_basebackup tar and starts it as a standby of the primary; a logical restore rebuilds the primary; logical subscribers are re-copied at the snapshot of a new slot. An automatic reseed only fills a node proven fresh, never a node holding data.
  • Maintenance. Scheduled vacuumdb --analyze, like the optimize and analyze jobs of MariaDB.

Routing, metrics and the rest

HAProxy in front of the cluster is repointed at every topology change, with the traffic marker and the write heartbeat of the MariaDB clusters. ProxySQL 3, which speaks the PostgreSQL wire protocol, can now front a PostgreSQL cluster too: Replication Manager drives its pgsql_* objects the way it drives the MySQL ones. The Graphs page shows the engine metrics from pg_stat_* (workload, WAL, vacuum), the resource usage of each server read from its cgroup, and the kernel's wait metrics next to the consumption. Sysbench runs through the proxy in one click, with the pgsql driver. An application deployed next to the cluster gets its database, role and grants created for it.

On our October benchmark, same hardware and same resource cap for every database, MariaDB and PostgreSQL were within 10 % of each other in throughput, and the three PostgreSQL topologies within 20 %.

What is covered, partial, or not there

Area PostgreSQL
Topology discovery, lag, standby state, health alerts yes
Processlist, variables, tables and sizes yes, processlist from pg_stat_activity, a mapped subset of variables
Slow log, query digest, performance schema no
Transaction log archive and point-in-time restore partial: WAL archive shipped; PITR restore planned; no flashback (no binary log)
Switchover, failover, rejoin yes, WAL streaming and logical
Semi-synchronous, GTID, delayed and multi-source replicas no equivalent
Logical and physical backups with progress pg_dumpall, pg_basebackup
Restore and reseed from a backup yes
Scheduled maintenance vacuumdb --analyze
HAProxy, traffic marker, write heartbeat yes
ProxySQL yes, ProxySQL 3
MaxScale, Spider no
Resource and engine metrics graphs yes
Users and grants audit, security score no
Database and role created for a linked application yes

The "no" lines are the honest part. The security score and the grants audit are built on the MariaDB privilege tables and have no PostgreSQL port yet; the query digest needs pg_stat_statements and is not wired. If one of them matters to you, say so: the roadmap follows the people who run it.

Where to run it

Replication Manager is open source, GPL v3, one binary, and runs where your databases are: on your own servers and orchestrators, or on Cloud18, our marketplace where a PostgreSQL cluster in any of the three topologies is created from the API, from the dashboard or from an AI assistant through the MCP server, provisioned on a partner's infrastructure and sized live by its plan.

Questions, a cluster to look at, a topology we should add: write to me, or open an issue. PostgreSQL support got where it is because people asked for it.