Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muuQL-0001Oi-HP for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 10:43:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1muuQI-0002YX-8i for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 10:43:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muuQH-0002YM-U4 for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 10:43:41 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muuQE-0003Xp-Nb for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 10:43:40 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id B35EC5C018B; Wed, 8 Dec 2021 05:43:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 08 Dec 2021 05:43:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=1/eQMh6ZmdP1qud7zuzFZFci8shY4yp+u0EPY+zbq 3w=; b=b+q4APd15T9sZLiMI+vgYSFysGI8YOrt0tr1IAqobRiwibDVqZ6/pewv8 SftzWHgz7HggVtQC/xa8KS92+h6qd4AVgFYYrmThHNKtOzX9Ibg4WZayuoEOcr9Z l7l2Ui1rJcacYP+Bvv4SLhjqee7lRXQAytHm1G2y/hEoAJ4jC3KiyslJh+opHCmN 5yMS05PjO653AIqAfmsip9CBbHibhEMbb+pbV24URO7XtGZxx4XsVjm8Vw8LEMTj f9fSuYrs17J0XejF+nUiB8huPQv/9jsRcyz34P06HGtSyML7jnP+bcFrMCpoqz8t oiBaq1mEeW6o+9c9uNus69aFJsBxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjeekgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeefjeegheetuefhveevudel ueeftdejteeiffetvdduhfdtieefgfeutedtveeggfenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Dec 2021 05:43:34 -0500 (EST) Message-ID: <37798fc0-d990-e531-f171-80e79f8f1c87@enterprisedb.com> Date: Wed, 8 Dec 2021 11:43:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: Are Foreign Key Disabled During Logical Replication Initial Sync? Content-Language: en-US To: Avi Weinberg , "pgsql-general@lists.postgresql.org" References: <6a957e68-9490-2cf3-e390-88cd7545251c@enterprisedb.com> From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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');