2ndQuadrant / pglogical

Logical Replication extension for PostgreSQL 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4 (Postgres), providing much faster replication than Slony, Bucardo or Londiste, as well as cross-version upgrades.
http://2ndquadrant.com/en/resources/pglogical/
Other
987 stars 153 forks source link

Update `forward_origins` for the existing subscription #452

Open shreyasp opened 8 months ago

shreyasp commented 8 months ago

I have created a subscription to synchronise the data between a virtual machine and a GCP CloudSQL instance. Before we promote the CloudSQL instance to handle all the traffic, we want to establish bi-directional replication so the existing virtual machine instance can stay as a redundant backup or failover instance.

To set up the bi-directional replication, we need to set forward_origins to {} instead of the default {all}. I checked the existing documentation and found no method to update forward_origins for an existing subscription.

I would be thankful if you could point me out a workaround or method that can update the value for forward_origins in the case of an existing subscription.

Thanks, Shreyas.

greenbea commented 8 months ago

I had the same issue. I solved it by disabling the subscription and updating the subscription table directly.

select * from pglogical.alter_subscription_disable('sub1, true);
update pglogical.subscription set sub_forward_origins = '{}' where sub_name = 'sub1';

I don't know how pglogical works under the hood, so I don't know if doing this is recommended in production.