Re: Are Foreign Key Disabled During Logical Replication Initial Sync?

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Avi Weinberg <AviW(at)gilat(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Are Foreign Key Disabled During Logical Replication Initial Sync?
Date: 2021-12-08 10:43:34
Message-ID: 37798fc0-d990-e531-f171-80e79f8f1c87@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07.12.21 08:51, Avi Weinberg wrote:
> Just to clarify, they are disabled during initial sync only or are always disabled on subscriber side?
> Are all triggers disabled during initial sync or just foreign keys?

All triggers are by default disabled on replicas. See the ALTER TABLE
clauses DISABLE/ENABLE [ REPLICA | ALWAYS ] TRIGGER to change this.

> How can I know that initial sync completed for all tables? Is it checking when pg_subscription_rel.srsubstate is 'i' or 'd' for all tables or there is a better way?

There are various ways to phrase this. The test suite often uses this
query:

SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN
('r', 's');

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2021-12-08 10:49:36 Re: error connecting to pgbouncer admin console
Previous Message Vikas Sharma 2021-12-08 10:25:20 Re: how to get value of parameter set in session for other user