Logical replication slot failover
PolarDB for PostgreSQL provides the logical replication slot failover feature, which synchronizes all logical replication slots from the primary node to the standby node to enable failover of logical replication slots.
Scope of application
This feature is available for the following PolarDB for PostgreSQL versions: PostgreSQL 11 with a minor engine version of 2.0.11.15.38.0 or later.
You can view the minor engine version in the console or by running the SHOW polardb_version; statement. If the minor engine version does not meet the requirements, upgrade the minor engine version。
Background information
Replication slots created on the primary node are not synchronized to the standby node through the streaming replication protocol. When a primary/standby switchover occurs, the replication slots are lost and logical subscriptions are interrupted. The logical replication slot failover feature of PolarDB for PostgreSQL synchronizes all logical replication slots from the primary node to the standby node to enable failover of logical replication slots.
-
PolarDB for PostgreSQL currently supports only failover for logical replication slots. Failover for physical replication slots is not supported.
-
For more information about logical replication slots, see the official documentation.
Enable or disable logical replication slot failover
You can enable or disable the logical replication slot failover feature by setting the polar_failover_slot_mode parameter on the Configure cluster parameters page in the console. Valid values:
-
sync: enables logical replication slot failover and sets the mode to synchronous.
Note-
Synchronous mode ensures that no data is lost for logical replication after a cluster HA failover.
-
Synchronous mode guarantees that no data is lost after an HA failover by ensuring that the logical replication client does not advance beyond the standby node. If the standby node is disconnected for an extended period and then reconnected, or is rebuilt, a time window occurs during which the latency between the primary and standby nodes increases significantly and the logical replication client may advance beyond the standby node. If an HA failover occurs during this period, data loss in logical replication cannot be guaranteed. In this case, in addition to the data loss caused by the HA failover itself, some data that was added on the new primary after the HA failover may also be lost.
To avoid the preceding data loss, Contact us to set the polar_priority_replication_force_wait parameter to on. During the standby disconnection period, the primary node waits until the standby node is reconnected or rebuilt, and does not send data to the logical replication client until then. This reduces the availability of logical replication. Proceed with caution.
-
-
async (default): enables logical replication slot failover and sets the mode to asynchronous.
Note-
Asynchronous mode ensures that no data is lost for logical replication after a cluster HA failover, but duplicate data may be sent to the logical replication client. If the logical replication client advances beyond the new primary node after the cluster HA failover, the logical replication client may also retain the data that was lost during the HA failover.
-
Unless you accept the potential data inconsistency after an HA failover in asynchronous mode, we recommend that you use synchronous mode.
-
-
off: disables logical replication slot failover.