RefLib

Reference library for AI

Back

postgresql_16:4.12.2.7 Cascading Replication

PostgreSQL 16 > Server Administration > High Availability, Load Balancing, and Replication > Log-Shipping Standby Servers > Cascading Replication

The cascading replication feature allows a standby server to accept replication connections and stream WAL records to other standbys, acting as a relay. This can be used to reduce the number of direct connections to the primary and also to minimize inter-site bandwidth overheads.

A standby acting as both a receiver and a sender is known as a cascading standby. Standbys that are more directly connected to the primary are known as upstream servers, while those standby servers further away are downstream servers. Cascading replication does not place limits on the number or arrangement of downstream servers, though each standby connects to only one upstream server which eventually links to a single primary server.

A cascading standby sends not only WAL records received from the primary but also those restored from the archive. So even if the replication connection in some upstream connection is terminated, streaming replication continues downstream for as long as new WAL records are available.

Cascading replication is currently asynchronous. Synchronous replication (see (see postgresql_16:4.12.2.8)) settings have no effect on cascading replication at present.

Hot standby feedback propagates upstream, whatever the cascaded arrangement.

If an upstream standby server is promoted to become the new primary, downstream servers will continue to stream from the new primary if recovery_target_timeline is set to 'latest' (the default).

To use cascading replication, set up the cascading standby so that it can accept replication connections (that is, set (see guc-max-wal-senders) and (see guc-hot-standby), and configure host-based authentication (see postgresql_16:4.6.1)). You will also need to set primary_conninfo in the downstream standby to point to the cascading standby.

Back