All Products
Search
Document Center

PolarDB:Logical replication slot failover

Last Updated:Apr 16, 2024

This topic describes the logical replication slot failover feature of PolarDB for PostgreSQL (Compatible with Oracle). If the primary node of a cluster fails, this feature can synchronize all logical replication slots to the read-only node.

Background information

The logical replication slots that are created in the primary node are not synchronized to the read-only in compliance with the streaming replication protocol. In the event of a failover, the logical replication slots are lost, and consequently the logical subscriptions are interrupted. The logical replication slot failover feature of PolarDB for PostgreSQL (Compatible with Oracle) can synchronize all logical replication slots from the primary node to the read-only node.

Note
  • PolarDB for PostgreSQL (Compatible with Oracle) supports only failover of logical replication slots. However, failover of physical replication slots is not supported.
  • For more information, see Logical Decoding Concepts.

Enable or disable the logical replication slot failover feature

You can enable or disable the logical replication slot failover feature by setting the polar_failover_slot_mode parameter. Default value: async. Valid values:
  • sync: enables the logical replication slot failover feature and sets it to synchronous mode.
    Note
    • The synchronous mode ensures that no data is lost in logical replication after the cluster uses HA.
    • The synchronous mode ensures that the logical replication client has newer data than the read-only node. This ensures that no data is lost in logical replication after the cluster uses HA. If the read-only node is disconnected for a long time and then reconnected, or the read-only node is rebuilt, a time window occurs. During this time window, the latency between the primary and read-only nodes is relatively high, and the logical replication client may have newer data than the read-only node. If the cluster uses HA 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 the preceding data loss, you can set the polar_priority_replication_force_wait parameter to on. When the read-only node is disconnected, the primary node waits till the read-only node is reconnected or rebuilt. No data is sent to the logical replication client before that. This reduces the availability of logical replication. Proceed with caution.

  • async: enables the logical replication slot failover feature and sets it to asynchronous mode.
    Note
    • In asynchronous mode, no data is lost in logical replication after the cluster uses HA. However, duplicate data may be sent to the client. If the logical replication client has newer data than the new primary node after HA, the logical replication client may retain the data lost during HA (if any).
    • If the inconsistent data affects your business, we recommend that you use the synchronous mode.
  • off: disables the logical replication slot failover feature.