Skip to content

Add ignore_slots support to Patroni DCS configuration#3021

Open
PavelZaytsev wants to merge 5 commits intozalando:masterfrom
PavelZaytsev:add-ignore-slots-dcs-config
Open

Add ignore_slots support to Patroni DCS configuration#3021
PavelZaytsev wants to merge 5 commits intozalando:masterfrom
PavelZaytsev:add-ignore-slots-dcs-config

Conversation

@PavelZaytsev
Copy link
Copy Markdown

@PavelZaytsev PavelZaytsev commented Dec 24, 2025

Motivation

PostgreSQL 17 introduced native logical replication slot synchronization, where logical slots are synced to standby servers. However, if both enabled, Patroni's logical slot failover inteferes resulting in a faulty behavior. This PR adds support for Patroni's ignore_slots DCS configuration to allow operators to exclude specific slot types (e.g., logical slots) from failover blocking.

Implementation

  • Add ignore_slots field to Patroni struct in CRD
  • Add ignore_slots to patroniDCS struct for Spilo configuration
  • Generate ignore_slots in SPILO_CONFIGURATION when specified
  • Update CRD manifest to accept ignore_slots field
  • Add unit test for ignore_slots configuration

This enables PostgreSQL 17 (and user-defined) slot synchronization support by allowing users to configure Patroni to ignore specific replication slot types (e.g., logical slots) during failover operations.

Users can now configure ignore_slots in their PostgreSQL manifest:

  patroni:
    ignore_slots:
      - type: logical

This instructs Patroni to ignore logical replication slots during failover.

Testing

  • Added unit test in k8sres_test.go for ignore_slots configuration
  • All existing tests pass
  • Manually verified in live cluster that ignore_slots appears in:
    • PostgreSQL CRD spec
    • SPILO_CONFIGURATION environment variable
    • Patroni's live configuration (patronictl show-config)

- Add ignore_slots field to Patroni struct in CRD
- Add ignore_slots to patroniDCS struct for Spilo configuration
- Generate ignore_slots in SPILO_CONFIGURATION when specified
- Update CRD manifest to accept ignore_slots field
- Add unit test for ignore_slots configuration

This enables PostgreSQL 17 native slot synchronization support by allowing
users to configure Patroni to ignore specific replication slot types (e.g.,
logical slots) during failover operations.

Users can now configure ignore_slots in their PostgreSQL manifest:

  patroni:
    ignore_slots:
      - type: logical

This instructs Patroni to ignore logical replication slots during failover,
which is essential for PostgreSQL 17's native logical slot synchronization
feature where slots are automatically synced to standbys.
@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@PavelZaytsev
Copy link
Copy Markdown
Author

Hi @mikkeloscar could someone from the maintainers team look into this PR when they get the chance/run CI/CD?

@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@PavelZaytsev
Copy link
Copy Markdown
Author

@FxKu @hughcapet @mikkeloscar can someone from the zalando team run the check-in pipeline on the PR plz

@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@baznikin
Copy link
Copy Markdown

baznikin commented Mar 24, 2026

Every cluster switchover leads to Debezium full initial snapshot.
We switched to failover slots, but after replica restarted it is trying to delete replication slot (and delete as soon as become master). We need this PR so badly

2026-03-24 11:28:48,489 INFO: no action. I am (payments-pg-0), a secondary, and following a leader (payments-pg-1)
2026-03-24 11:28:58,478 INFO: Lock owner: payments-pg-1; I am payments-pg-0
2026-03-24 11:28:58,483 ERROR: Exception when changing replication slots
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/slots.py", line 549, in sync_replication_slots
    self._drop_incorrect_slots(cluster, slots)
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/slots.py", line 347, in _drop_incorrect_slots
    active, dropped = self.drop_replication_slot(name)
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/slots.py", line 324, in drop_replication_slot
    rows = self._query(('WITH slots AS (SELECT slot_name, active'
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/slots.py", line 205, in _query
    return self._postgresql.query(sql, *params, retry=False)
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/__init__.py", line 408, in query
    return self._query(sql, *params)
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/__init__.py", line 385, in _query
    return self._connection.query(sql, *params)
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/connection.py", line 84, in query
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/patroni/postgresql/connection.py", line 74, in query
    cursor.execute(sql.encode('utf-8'), params or None)
psycopg2.errors.ObjectNotInPrerequisiteState: cannot drop replication slot "debezium"
DETAIL:  This replication slot is being synchronized from the primary server.

2026-03-24 11:28:58,502 INFO: no action. I am (payments-pg-0), a secondary, and following a leader (payments-pg-1)

@ToGoBananas
Copy link
Copy Markdown

ToGoBananas commented Mar 24, 2026

@FxKu @hughcapet
It looks like serious issue with Postgres 17+ feature support. Please think about including this in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants