Skip to content

Use PG17+ failover slots when creating replication slots #1627

@altmannmarcelo

Description

@altmannmarcelo

Summary

PostgreSQL 17 introduced failover slots (CREATE_REPLICATION_SLOT ... (FAILOVER)), which allow logical replication slots to be synchronized to physical standbys. When a standby is promoted, the slot survives with its confirmed_flush_lsn intact, enabling subscribers to reconnect without a full resnapshot.

Readyset should use this option when creating replication slots on PG17+ servers. This is a small change that gives free failover resilience.

Current behavior

Readyset creates replication slots with:

CREATE_REPLICATION_SLOT <name> LOGICAL pgoutput EXPORT_SNAPSHOT

When the primary fails over to a standby, the slot is lost, and Readyset must do a full resnapshot against the new primary.

Proposed change

When server_version_num >= 170000, use the PG17 parenthesized option syntax with the FAILOVER flag:

CREATE_REPLICATION_SLOT <name> LOGICAL pgoutput (FAILOVER, SNAPSHOT 'export')

For older versions, keep the existing syntax unchanged.

Files to change

  • replicators/src/postgres_connector/connector.rscreate_replication_slot(): accept version parameter, conditionally add FAILOVER
  • replicators/src/noria_adapter.rs — pass version_num through to create_replication_slot()

Impact

  • PG17+: Slot survives failover to a promoted standby → no resnapshot needed
  • PG < 17: No change in behavior (existing full-resnapshot fallback still works)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions