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

From: Avi Weinberg <AviW(at)gilat(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(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-07 07:51:33
Message-ID: DB9PR07MB7180EA671641A151268ADE51CB6E9@DB9PR07MB7180.eurprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Peter,

Thanks for answer.

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?
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?

Thanks!

-----Original Message-----
From: Peter Eisentraut [mailto:peter(dot)eisentraut(at)enterprisedb(dot)com]
Sent: Tuesday, December 7, 2021 7:19 AM
To: Avi Weinberg <AviW(at)gilat(dot)com>; pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Are Foreign Key Disabled During Logical Replication Initial Sync?

On 06.12.21 15:50, Avi Weinberg wrote:
> Does it mean that populating each table is done in a single
> transaction? If so, when I have tables with foreign keys between
> them, is it guaranteed that logical replication will populates the
> tables in the proper order so the foreign key will be enforced? Or
> maybe the foreign keys are disabled during initial sync and only after
> all tables are populated the FKs are enabled again.

Foreign keys are disabled on logical replication subscribers.

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Klaudie Willis 2021-12-07 09:15:57 When Update balloons memory
Previous Message Nick Cleaton 2021-12-07 07:07:37 Re: Advice on using materialized views