Comments on: How Patroni Addresses the Problem of the Logical Replication Slot Failover in a PostgreSQL Cluster https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/ Mon, 15 Apr 2024 15:32:07 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Shaan https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10974289 Mon, 15 Apr 2024 15:32:07 +0000 https://www.percona.com/blog/?p=79769#comment-10974289 below comment can be ignored and removed.

]]>
By: Shaan https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10974286 Fri, 12 Apr 2024 16:43:36 +0000 https://www.percona.com/blog/?p=79769#comment-10974286 hi Jobin, I followed your steps and added the below but i still don’t see the logical slot in the database. Is there anything i am missing?

slots:
logicreplica:
database: test1
plugin: pgoutput
type: logical

test1=# select * from pg_replication_slots;
-[ RECORD 1 ]——-+———————–
slot_name      | patroni_pgcluster_qa02
plugin       | 
slot_type      | physical
datoid       | 
database      | 
temporary      | f
active       | t
active_pid     | 38817
xmin        | 
catalog_xmin    | 
restart_lsn     | 0/9898D90
confirmed_flush_lsn | 
wal_status     | reserved
safe_wal_size    | 
two_phase      | f
-[ RECORD 2 ]——-+———————–
slot_name      | patroni_pgcluster_qa03
plugin       | 
slot_type      | physical
datoid       | 
database      | 
temporary      | f
active       | t
active_pid     | 38815
xmin        | 
catalog_xmin    | 
restart_lsn     | 0/9898D90
confirmed_flush_lsn | 
wal_status     | reserved
safe_wal_size    | 
two_phase      | f

]]>
By: Stefan https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10974226 Thu, 14 Dec 2023 12:27:35 +0000 https://www.percona.com/blog/?p=79769#comment-10974226 I’m stuck on an issue with Patroni and logical replication. I’ve been able to set all this up but now when logical replication starts I get a “publication does not exist” error. The publication does exist, in fact! The same case is documented here by someone else: https://postgrespro.com/list/thread-id/2492943 But there is no solution on the post. From what I understand, if you create the slot before your create the publication, then the slot does not know about the existence of the publication. I do not have control on when Patroni creates the slot and everything I have tried so far creates the publication after the slot is created, because I deploy the table/publication creation scripts after starting a new Patroni cluster on Kubernetes. Does anyone know how to resolve this?

]]>
By: Dominik Kroutvar https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10974209 Thu, 16 Nov 2023 09:37:01 +0000 https://www.percona.com/blog/?p=79769#comment-10974209 Great post! I have set up a new Postgres cluster on my openshift cluster with 1 master and 2 replicas according to this recommendation. I have also configured 1 replication slot. Now I would like to monitor the health of the cluster. Therefore I have created an alert to fire if pg_exporter_last_scrape_error returns a value greater than 0. This metric works on the master as expected but all replicas return 1 instead of 0. Is this intended? Am I making a mistake in my thinking? Are there any tips on how and what is best to monitor in this scenario?

]]>
By: Bert https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973839 Thu, 24 Nov 2022 17:03:47 +0000 https://www.percona.com/blog/?p=79769#comment-10973839 It’s a nice feature! Using this feature requires adding slot information to the patroni.yml configuration file in advance. If the user add a subscription(include slot) without pre-creating replication slot in this way,What’s a good way for me to find it in time and add it to the configuration file to avoid the loss of replication slot information after switching.Thanks!

]]>
By: Jobin Augustine https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973528 Sat, 05 Feb 2022 07:08:23 +0000 https://www.percona.com/blog/?p=79769#comment-10973528 Hi Deepak, In this post, I am discussing about built-in native logical replication in PostgreSQL and slot maintenance for replication to downstream systems. No need to create any extension for it.

]]>
By: Deepak https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973524 Thu, 03 Feb 2022 12:33:27 +0000 https://www.percona.com/blog/?p=79769#comment-10973524 I had setup like this but my logical replication is not working .Reason being ,Patorni’s physical slot already in place .

Please note I have already set all parameters like wal_levle= logical and shared_preload_lib as well to logical and created extension as well but still logical replication is not working . Whenever i’m trying to create table on STANDBY ,its saying can’t create d/table in read only transaction

]]>
By: Jobin Augustine https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973511 Wed, 26 Jan 2022 11:49:59 +0000 https://www.percona.com/blog/?p=79769#comment-10973511 Conceptually Yes, Standby can serve the request. But If you are thinking about leveraging standby as a publisher, it won’t be possible now because logical decoding is not yet allowed on standby.

]]>
By: pcpg https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973508 Tue, 25 Jan 2022 15:48:54 +0000 https://www.percona.com/blog/?p=79769#comment-10973508 Sorry, I realised that my query was not what I actually wanted to ask.

Let me re-ask: so the standby needs to be a synchronous (streaming replication) standby. A change on primary, that is acknowledged to the client (application), will definitely be available on the standby and because the slot is maintained on the standby too, the subscriber can request the standby from the point till which replication was done. Correct?

]]>
By: Jobin Augustine https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973507 Tue, 25 Jan 2022 15:25:54 +0000 https://www.percona.com/blog/?p=79769#comment-10973507 You are welcome 🙂 . No need to worry even if slot on the standby lags.
because it is the subscriber who makes the request so the slot will be automatically advanced.

]]>
By: Jobin Augustine https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973506 Tue, 25 Jan 2022 14:57:56 +0000 https://www.percona.com/blog/?p=79769#comment-10973506 Sorry @Michael for being late. Yes Thats indeed a great idea. That can eliminate use of HAProxy
Being a libpq connection that should work 🙂 . But I am yet to test

]]>
By: Michael Banck https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973500 Tue, 18 Jan 2022 11:02:26 +0000 https://www.percona.com/blog/?p=79769#comment-10973500 Great post! Do you know whether it is possible to write all the hostnames into the subscriber connection string and target_session_attrs=read-write, so that the subscription would be reset to the new primary automatically?

]]>
By: pcpg https://www.percona.com/blog/how-patroni-addresses-the-problem-of-the-logical-replication-slot-failover-in-a-postgresql-cluster/#comment-10973498 Sat, 15 Jan 2022 04:45:07 +0000 https://www.percona.com/blog/?p=79769#comment-10973498 Good to know this development by Patroni. Thanks for sharing in such detail. Could there be a scenario where the primary goes down before the slot is advanced on standby?

]]>