Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying replication slots #3900

Open
Pluggi opened this issue Apr 24, 2024 · 3 comments
Open

Deploying replication slots #3900

Pluggi opened this issue Apr 24, 2024 · 3 comments

Comments

@Pluggi
Copy link

Pluggi commented Apr 24, 2024

Hello,

I am looking to replicate a table from one PGO cluster to another. For that, I wanted to use Postgres replication slots and Patroni's dynamic configuration use_slots to ensure it is created on the leader and its replicas and continue working in case of a failover.

However I found this piece of code which forces it to false : https://github.com/CrunchyData/postgres-operator/blob/master/internal/patroni/config.go#L207

What was the rationale behind this setting? What could go wrong if I set it to true ? Can it change the behavior of the replication inside a PGO cluster?

@andrewlecuyer
Copy link
Collaborator

Hi @Pluggi! Thanks for reaching out.

By default, PGO leverages pgBackRest for the management of WAL archives (meaning pgBackRest ensures WAL is properly archived and available to the various replicas within the PostgresCluster - while also providing a ton of great features to ensure WAL is effectively and efficiently archived & available). So because of this, PGO simply sets use_slots to false by default.

That being said, PGO does allow this setting to be turned on. In fact, certain functionality provided by the HA system (Patroni) requires use_slots to be enabled:

https://patroni.readthedocs.io/en/latest/dynamic_configuration.html#dynamic-configuration-settings

slots: define permanent replication slots.
...
Enabling permanent replication slots requires postgresql.use_slots to be set to true.

So use of the setting really depends on your use. And I'll note that if you are seeing any issues with WAL that has you reaching this setting, I would definitely be curious to hear any further details/specifics.

Hope this helps!

@Pluggi
Copy link
Author

Pluggi commented Jun 3, 2024

Hello !

It's not clear to me what pgbackrest has to do with patroni using replication slots? I thought the writing of WAL files to disk was enabled using archive_mode.

My use case is, we have two PGO clusters A and B. I want to replicate data from table T in cluster A to cluster B.
The most simple way to do that seemed to be to just use replication slots.
However, I think if I just deploy replication slots using pg_create_physical_replication_slot() on the leader of cluster A and then a failover happens on cluster A, the replication slot will not be automatically recreated on the new leader? So I wanted to use Patroni for that.

@tjmoore4
Copy link
Contributor

Hi @Pluggi. To follow up on this issue, based on your description above, have you considered using one of PGO's built in standby cluster options? There are examples in the documentation that should be useful if you decide to try this out. Hope this helps!

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

No branches or pull requests

3 participants