CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL Logical Replication

Replicate one table into a writable database on another cluster. Then add a column on the publisher and watch the apply worker die while the subscription still reports itself enabled.

Replication Guide 32 of 47 Advanced

PostgreSQL 18 validates the subscription's target relations when you run CREATE SUBSCRIPTION, so a missing table is refused immediately. On earlier versions the subscription is created and the worker fails afterwards.

The 3 hosts these commands ran on: db-a01, db-b01, db-c01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB
db-b01192.168.0.82Ubuntu 26.04 LTSStandby / Replica / Replica Set Member 22 Core4 GB50 GB
db-c01192.168.0.83Ubuntu 26.04 LTSReplica Set Member 3 / Cascading and Delayed Replica2 Core4 GB50 GB

This guide includes

Use this when one table has to reach a writable database on another cluster. This matters because logical replication is not physical - the subscriber stays writable and the schema is not replicated, and both of those are traps.

Before you start

  1. Logical decoding needs more in the WAL than replication does

  2. Publish a subset

  3. The subscriber connects to a database, not to `replication`

  4. The schema is not replicated either

  5. Watch changes flow

  6. The subscriber is writable, and that is the trap

  7. Add a column, and break it

  8. Tear it down properly

Official sources