feat(cluster): expose replicationSlots on the CNPG Cluster#877
Open
philippemnoel wants to merge 1 commit into
Open
feat(cluster): expose replicationSlots on the CNPG Cluster#877philippemnoel wants to merge 1 commit into
philippemnoel wants to merge 1 commit into
Conversation
Surfaces CloudNativePG's `spec.replicationSlots` on the cluster chart so chart users can enable synchronization of user-created logical replication slots between the primary and standbys. With PostgreSQL 17+ failover slots, this lets CDC consumers (e.g. Debezium) survive a CNPG failover without losing the slot. To make logical decoding slots survive failover, users must: - enable `cluster.replicationSlots.highAvailability.synchronizeLogicalDecoding` - set `cluster.postgresql.parameters.hot_standby_feedback: "on"` - set `cluster.postgresql.parameters.sync_replication_slots: "on"` - create the CDC client's logical slot with `failover = true` Requires CloudNativePG 1.27+ and PostgreSQL 17+ for native failover slots. The block is omitted entirely when the value is empty, so existing deployments are unaffected. The non-default-configuration chainsaw test is extended with a `replicationSlots` block and the matching PostgreSQL parameters, and asserts they appear verbatim on the rendered Cluster CR. Signed-off-by: Philippe Noël <philippemnoel@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Cluster.spec.replicationSlotson theclusterchart throughcluster.replicationSlots.Why
CDC tools (Debezium, Artie, etc.) create and consume a logical replication slot on the current primary. Before this change, a CNPG switchover or failover could leave that logical slot behind on the old primary, which then becomes a replica. CDC stops reconnecting cleanly and the abandoned slot can continue retaining WAL.
CloudNativePG can coordinate logical decoding slot synchronization across HA instances via
spec.replicationSlots, but theclusterchart did not previously surface that field, so chart users had no way to enable it without bypassing the chart.Requirements for CDC failover
cluster.replicationSlots.highAvailability.synchronizeLogicalDecoding: true.cluster.postgresql.parameters.hot_standby_feedback: "on".cluster.postgresql.parameters.sync_replication_slots: "on".failover = true; CNPG cannot move a normal non-failover logical slot.synced = true,temporary = false, andinvalidation_reason IS NULL.Backwards compatibility
cluster.replicationSlotsdefaults to{}, and the template uses{{- with ... }}so the block is omitted entirely when unset. Existing deployments render identically.Tests
helm lint charts/clusterhelm template test charts/cluster --show-only templates/cluster.yaml(noreplicationSlotsrendered by default)helm template test charts/cluster --show-only templates/cluster.yaml --values charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml(rendersreplicationSlotsverbatim)postgresql-cluster-configurationtest now asserts the renderedreplicationSlotsblock.