By default, PostgreSQL's streaming replication protocol does not sync logical replication slots from the primary node to the standby node. If a failover occurs, the slot is lost and all logical subscriptions are disrupted. PolarDB for PostgreSQL resolves this by syncing logical replication slots to the standby node so that subscriptions continue seamlessly after a failover.
Physical replication slot failover is not supported. For background on how replication slots work, see Replication slots in the PostgreSQL documentation.
Enable or disable logical replication slot failover
Control logical replication slot failover by setting the polar_failover_slot_mode parameter. Configure the parameter in the console.
Choose a mode
| Mode | Behavior | Data safety | Use when |
|---|---|---|---|
async (default) | Syncs slots asynchronously. No data loss during HA cluster failover. The logical replication client may receive duplicate data after failover. If the client has newer data than the new primary after failover, it may have retained data that was lost during failover. | No loss during HA failover; possible duplicates | Most workloads; duplicate data is acceptable |
sync | Syncs slots synchronously. Ensures the logical replication client never receives changes ahead of the standby node. No data loss during failover. | No loss during failover; see edge case below | Data consistency is critical |
off | Disables logical replication slot failover. | Not applicable | Failover for logical replication is not needed |
In sync mode, an edge case exists: if the standby node disconnects for an extended period or is being rebuilt, the primary-standby sync latency can grow large enough that the logical replication client receives changes ahead of the standby. If a failover occurs in this window, data may be lost in logical replication, and data generated on the new primary may also be lost. To prevent this, contact support to set polar_priority_replication_force_wait to on. This prevents the primary from sending changes to the logical replication client until the standby reconnects or finishes rebuilding. Note that this reduces the availability of logical replication during disconnection periods.
If duplicate data from async mode affects your workload, switch to sync mode.
Limitations
Physical replication slot failover is not supported.