User Guide · PostgreSQL · Logical replication & DR

Logical replication & disaster recovery

PostgreSQL logical replication copies row changes between clusters. Jarwis uses it in two ways: a managed DR link between two clusters with a controlled, approved switchover, and direct management of publications, subscriptions and slots for your own data flows.

/clusters/2?tab=cross-replication
Cross-Replication tab on a PostgreSQL cluster with Disaster recovery panel, Logical replication panel with wal_level warning, publications, subscriptions and replication slots
The Cross-Replication tab on a PostgreSQL cluster: the Disaster recovery (logical replication) panel with + Add DR link, then the Logical replication panel with a wal_level=replica warning and an Enable logical button, followed by Publications, Subscriptions and the Replication slots table.

DR link between two PostgreSQL clusters

Open the primary cluster's Cross-Replication tab (?tab=cross-replication) and create a link to a second PostgreSQL cluster (typically in another data centre). Choose which databases to replicate — by default every user database. If wal_level has to change to logical, tick allow restart; without it the request is refused rather than restarting a database unexpectedly.

  • Jarwis creates the roles, schema and initial data copy on the DR side, then streams changes continuously. Status goes installing → syncing → running and the link shows replication lag.
  • On Patroni clusters the replication slot is registered as a permanent slot, so it survives a failover of the source.
  • The DR cluster is read-only for applications while it is the standby.

Planned switchover

A switchover moves the primary role to the DR cluster with no data loss. It is destructive for the running application, so it needs approval: request it, an administrator approves, then it executes. Jarwis waits for the standby to catch up, makes the old primary read-only, synchronises sequences on the new primary (so inserts do not collide on primary keys), opens the new primary for writes and reverses the stream so the old primary becomes the standby. Switch back the same way.

Failover If the primary is lost, fail over to the DR cluster from the link's actions. Changes not yet replicated are lost — the link records the failover time so you can reconcile later. Re-establish the link afterwards to resynchronise.

Publications, subscriptions and slots

The cluster's logical replication view (/pg-logical in the API) shows wal_level, publications, subscriptions with their state and pending tables, and replication slots with the WAL they retain. You can enable logical replication (restart needed), create or drop publications and edit their table lists, create subscriptions against another Jarwis-managed cluster (with or without the initial copy), enable, disable or refresh them. Objects owned by a DR link are marked and cannot be modified by hand.

An inactive slot keeps WAL on disk indefinitely. Jarwis raises an inactive slot bloat alert and lets you drop an inactive slot (an active slot is refused).

What logical replication does not copy DDL (schema changes), sequences' current values (apart from the switchover sync) and large objects are not replicated continuously. Apply schema changes on both sides before relying on a DR link.