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 1lO9qQ-0001x4-Cu for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Mar 2021 01:59:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lO9qO-0002Dq-Mf for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Mar 2021 01:59:00 +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 1lO9qN-0002D0-Ms for pgsql-hackers@lists.postgresql.org; Mon, 22 Mar 2021 01:59:00 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lO9qK-0002tK-S6 for pgsql-hackers@lists.postgresql.org; Mon, 22 Mar 2021 01:58:58 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 2AF7A5C00F5; Sun, 21 Mar 2021 21:58:56 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Sun, 21 Mar 2021 21:58:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=QfUTC+x74bi1B7rFjL306o8wBtHLI0Z aLaQyvGajeQE=; b=E5Vx/egDVoVghlB08dfGI/8/gN31m77o1fwCZPA3I+own0Q rdsn82JQvVZyzJJds6rKwAtvZiFj0i2M1crIiCtTQQMVEjYlTMJtKVqB+K2AecOV M3MYLyL/FfpdEiOnQWdOCI+jauUbddPE9vDhoXloY/neg91sCbgxFnTN/1VgFWzw 2Bf0m7Z/0KZFAtdmq4/Vg6nE/9uPNU1YJXfQ5lKBCl2w9+XaujULl+Rw8ZgHbsOA n8GxRWjVZnVXxwPLWcP5m8E9ORKChyL7u7pfdFe/8i18riMZgLpBUoT3CfNihekW ztzYupNLRXgjluz6nL3+GKmbzA9Br5hRrfYfQ/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; bh=QfUTC+ x74bi1B7rFjL306o8wBtHLI0ZaLaQyvGajeQE=; b=lpQdYdveyt0Kz981mxPu/v /aOZqkLSXp06GZrZDhFV8tV11OqkMyeOgo6p2afE3QnJurk8hGGFxNlC1FiDtlMt Ep+WpKRrIT+s1Lle4MjrBmALlceSLJ8NCgnr4SkqNi6jjZImIIUNCTl0hJzFl9CJ YPriL3YyzhxOCKglTRKDaq9RWrqhMIgiMC640m+DVPBRb9KzIPFYswmwNgh8smdW bfRMYZoXzyM01nnJHWW7Y5RsRSiX6MNbwhPv/pMI2WCe4yHYbj/Ghk6Nv3xtYJ8X iFV6DXPtAIRM5oLrIDry3y+rXSmvxY3Ounu2f5uJNMh+DBxlB4VsK8GLmSHzPeBA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegfedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesrgdtreerreertdenucfhrhhomhepfdfguhhl vghrucfvrghvvghirhgrfdcuoegvuhhlvghrsegvuhhlvghrthhordgtohhmqeenucggtf frrghtthgvrhhnpeejtefhuedvgffftdetvedufedtjeeuffekleevkefhveekgeelfefh jeehtdejgeenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvghulhgvrhesvghu lhgvrhhtohdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id A6DDB51C005E; Sun, 21 Mar 2021 21:58:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-206-g078a48fda5-fm-20210226.001-g078a48fd Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20191128023201.GH237562@paquier.xyz> <20200116215730.vq6ark7uycmvwxtx@development> <2963266d-07b5-aed3-7cbe-2d5f2bc0b453@pgmasters.net> <8cf1ea71-b609-00e8-b8f0-c85ba61b7312@pgmasters.net> <4dbad191-9b40-4bb6-8940-d18f2e93c3ce@www.fastmail.com> <5b9fceed-8f91-467f-a64e-2134c5c3f496@www.fastmail.com> <52edc9d2-8e52-4cde-9a15-991961b78387@www.fastmail.com> <9d5ef845-391a-4c66-b298-0f594d9e6828@www.fastmail.com> Date: Sun, 21 Mar 2021 22:58:14 -0300 From: "Euler Taveira" To: "Rahila Syed" Cc: =?UTF-8?Q?=C3=96nder_Kalac=C4=B1?= , japin , "Michael Paquier" , "David Steele" , "Craig Ringer" , "Tomas Vondra" , "Amit Langote" , "PostgreSQL Hackers" Subject: Re: row filtering for logical replication Content-Type: multipart/alternative; boundary=e7dc30bfcb4b41daaa2df240224c95f6 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --e7dc30bfcb4b41daaa2df240224c95f6 Content-Type: text/plain On Tue, Mar 9, 2021, at 12:05 PM, Rahila Syed wrote: > Please find some comments below: Thanks for your review. > 1. If the where clause contains non-replica identity columns, the delete performed on a replicated row > using DELETE from pub_tab where repl_ident_col = n; > is not being replicated, as logical replication does not have any info whether the column has > to be filtered or not. > Shouldn't a warning be thrown in this case to notify the user that the delete is not replicated. Isn't documentation enough? If you add a WARNING, it should be printed per row, hence, a huge DELETE will flood the client with WARNING messages by default. If you are thinking about LOG messages, it is a different story. However, we should limit those messages to one per transaction. Even if we add such an aid, it would impose a performance penalty while checking the DELETE is not replicating because the row filter contains a column that is not part of the PK or REPLICA IDENTITY. If I were to add any message, it would be to warn at the creation time (CREATE PUBLICATION or ALTER PUBLICATION ... [ADD|SET] TABLE). > 2. Same for update, even if I update a row to match the quals on publisher, it is still not being replicated to > the subscriber. (if the quals contain non-replica identity columns). I think for UPDATE at least, the new value > of the non-replicate identity column is available which can be used to filter and replicate the update. Indeed, the row filter for UPDATE uses the new tuple. Maybe your non-replica identity column contains NULL that evaluates the expression to false. > 3. 0001.patch, > Why is the name of the existing ExclusionWhereClause node being changed, if the exact same definition is being used? Because this node ExclusionWhereClause is used for exclusion constraint. This patch renames the node to made it clear it is a generic node that could be used for other filtering features in the future. > For 0002.patch, > 4. + > + memset(lrel, 0, sizeof(LogicalRepRelation)); > > Is this needed, apart from the above, patch does not use or update lrel at all in that function. Good catch. It is a leftover from a previous patch. It will be fixed in the next patch set. > 5. PublicationRelationQual and PublicationTable have similar fields, can PublicationTable > be used in place of PublicationRelationQual instead of defining a new struct? I don't think it is a good idea to have additional fields in a parse node. The DDL commands use Relation (PublicationTableQual) and parse code uses RangeVar (PublicationTable). publicationcmds.c uses Relation everywhere so I decided to create a new struct to store Relation and qual as a list item. It also minimizes the places you have to modify. -- Euler Taveira EDB https://www.enterprisedb.com/ --e7dc30bfcb4b41daaa2df240224c95f6 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Tue, Ma= r 9, 2021, at 12:05 PM, Rahila Syed wrote:
Please= find some comments below:
Thanks= for your review.

1. If the wh= ere clause contains non-replica identity columns, the delete performed o= n a replicated row
 using DELETE from pub_tab where r= epl_ident_col =3D n;
is not being replicated, as logical&n= bsp;replication does not have any info whether the column has
=
to be filtered or not. 
Shouldn't a warning= be thrown in this case to notify the user that the delete is not replic= ated.
Isn't documentation e= nough? If you add a WARNING, it should be printed per row,
hence, a huge DELETE will flood the client with WARNING messages by def= ault. If
you are thinking about LOG messages, it is a diff= erent story. However, we
should limit those messages to on= e per transaction. Even if we add such an aid,
it would im= pose a performance penalty while checking the DELETE is not
replicating because the row filter contains a column that is not part = of the PK
or REPLICA IDENTITY. If I were to add any messag= e, it would be to warn at the
creation time (CREATE PUBLIC= ATION or ALTER PUBLICATION ... [ADD|SET] TABLE).

2. Same for update, even if I update a row to match the q= uals on publisher, it is still not being replicated to 
the subscriber. (if the quals contain non-replica identity colum= ns). I think for UPDATE at least, the new value
of the non= -replicate identity column is available which can be used to filter and = replicate the update.
Indee= d, the row filter for UPDATE uses the new tuple. Maybe your non-replica<= br>
identity column contains NULL that evaluates the expressio= n to false.

3. 0001.patch, 
Why is the name of the existing ExclusionWhereClause n= ode being changed, if the exact same definition is being used?
=
Because this node ExclusionWhereClau= se is used for exclusion constraint. This
patch renames th= e node to made it clear it is a generic node that could be used
for other filtering features in the future.

For 0002.patch,
4.   +
<= /div>
 +       memset(lrel, 0, sizeof(LogicalRep= Relation));

Is this needed, apart fro= m the above, patch does not use or update lrel at all in that function.<= br>
Good catch. It is a leftover from= a previous patch. It will be fixed in the
next patch set.=

=
5.  PublicationRelation= Qual and PublicationTable have similar fields, can PublicationTable
<= /div>
be used in place of PublicationRelationQual instead of definin= g a new struct?
I don't think it = is a good idea to have additional fields in a parse node. The
<= div>DDL commands use Relation (PublicationTableQual) and parse code uses= RangeVar
(PublicationTable). publicationcmds.c uses Relat= ion everywhere so I decided to
create a new struct to stor= e Relation and qual as a list item. It also minimizes the places
you have to modify.


--
Euler Taveira

--e7dc30bfcb4b41daaa2df240224c95f6--