PolarDB for PostgreSQL Logical Replication Slot Failover feature synchronizes all logical replication slots from the primary node to standby nodes, enabling failover of logical replication slots.
Prerequisites
The following PolarDB for PostgreSQL versions support this feature:
PostgreSQL 11 (minor engine version 1.1.27 and later)
You can check the minor engine version by running SHOW polar_version
. If your version does not meet the requirements, upgrade your version.
Background information
Replication slots created on the primary node are not synchronized to standby nodes through the streaming replication protocol. When a cluster performs a failover, replication slots are lost, which causes logical subscription interruption. The PolarDB for PostgreSQL Logical Replication Slot Failover feature synchronizes all logical replication slots from the primary node to standby nodes, enabling failover of logical replication slots.
PolarDB for PostgreSQL currently supports only logical replication slot failover. Physical replication slot failover is not supported.
For more information, see the official documentation.
Enable or disable the logical replication slot failover feature
You can set the cluster parameter polar_failover_slot_mode in the console to enable or disable the logical replication slot failover feature. The parameter values are as follows:
sync: enables the logical replication slot failover feature and sets it to synchronous mode.
NoteThe synchronous mode ensures that no data is lost in logical replication after a cluster failover.
The synchronous mode ensures that logical replication clients do not get ahead of standby nodes, which prevents data loss in logical replication after a failover. If a standby node disconnects for a long time and then reconnects, or if a standby node is rebuilt, there will be a time window during which the latency between the primary and standby nodes is high, and logical replication clients may get ahead of the standby node. If a failover occurs during this time window, data may be lost in logical replication. In addition to the lost data during the failover, the data that is generated on the new primary node after HA also may be lost.
To avoid data loss, you can contact us to set the polar_priority_replication_force_wait parameter to on. When a standby node is disconnected, the primary node waits for the standby node to reconnect or be rebuilt before sending data to logical replication clients. This reduces the availability of logical replication. Proceed with caution.
async (default): enables logical replication slot failover and sets it to the asynchronous mode.
NoteThe asynchronous mode ensures that no data is lost in logical replication after a cluster failover. However, duplicate data may be sent to logical replication clients. If logical replication clients get ahead of the new primary node after a cluster failover, the logical replication clients may still have data that was lost during the failover (if data loss occurred during the failover).
If the inconsistent data affects your business, we recommend that you use the synchronous mode.
off: disables the logical replication slot failover feature.