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 1pf5qh-0004tj-W1 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Mar 2023 21:18:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pf5qg-0005w7-QD for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Mar 2023 21:18:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pf5qe-0005vy-VS for pgsql-hackers@lists.postgresql.org; Wed, 22 Mar 2023 21:18:22 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pf5qV-0001JF-Td for pgsql-hackers@lists.postgresql.org; Wed, 22 Mar 2023 21:18:20 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id B21375C0136; Wed, 22 Mar 2023 17:18:09 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute6.internal (MEProxy); Wed, 22 Mar 2023 17:18:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1679519889; x=1679606289; bh=FR r2dhGcrg585EKs0ZL+UG+GD9FerDwvK7tTLkSXHLU=; b=yFtClGvLO4wzV0drrq 4zpAwBkmfe+7OX5JhVDg3pqxzQCzEgWh9WBnOPBBvxYuq5FuVhd8U5Qwo+7mVEey Hq73KZnqgLIJxymViGYkTVemWVRm3WWpSFRWmnwHbXvP6vYWfDR/s/gM1Vetr0HF QKNZW+7hFF4/hGosgy7rwsm5RoRFhYquj79qiFDOyqDxUdMN08QmBlAPFLV5viT9 IJQcUkeAw02lgCtVPGpr0SzcepCM0ac4dNpOuw//8ft/fHhh8d2YR8iSrpECGs3s pAymVFUC5wI5TZrloJk79duNS/KbqK2gXxUfHxnnQTiHNgu2ldAaz7hjTcTq0eSD 19UA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1679519889; x=1679606289; bh=FRr2dhGcrg585 EKs0ZL+UG+GD9FerDwvK7tTLkSXHLU=; b=Hfx4efiO6Yvx4ybywVsGIWoFQEZoS JlVzcufmwqFM3ZZVpHd+jR/+SQQeyTJr8iNs2vWkRyl0hR2HD3gFPDiVieuusJwV PGd2UOc4ufkmWgoRBKEgOxmvOE1dMtkrOBLks3oG+ZZ+MQIghauWDLEfZ+V4/1Q2 Ql8Y9/RbWjEwr7I3/CYRf/8+O2ipIl/shLDDxnezjQCcmGckySAcmSVSsGQoIOSn 3JP/U/TOeAKrpyHDrY9hk1etrO6BMIMI+H0mxa8SCbWjak8r2TP18xNvvHtJ6uJe 0MAPxB3/Gp/FvgBtOZ92PzSkio8I+PUXynYGePXUdFCL+KUBadaeSXU7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegvddgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreertdenucfhrhhomhepfdfg uhhlvghrucfvrghvvghirhgrfdcuoegvuhhlvghrsegvuhhlvghrthhordgtohhmqeenuc ggtffrrghtthgvrhhnpeehvdevueeljeekfeeliefhfeefgfffgeeufefhvdeugedttdeg vdehuedvgfdugfenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgpdgvnhhtvg hrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegvuhhlvghrsegvuhhlvghrthhordgtohhm X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6E9B815A008E; Wed, 22 Mar 2023 17:18:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-236-g06c0f70e43-fm-20230313.001-g06c0f70e Mime-Version: 1.0 Message-Id: <78149fa6-4c77-4128-8518-197a631c29c3@app.fastmail.com> In-Reply-To: References: <20230318120638.3z7usvxwncs47tdy@alvherre.pgsql> <22c275cc-a2d5-4cee-ac81-bbb6950248b8@app.fastmail.com> Date: Wed, 22 Mar 2023 18:17:49 -0300 From: "Euler Taveira" To: "Amit Kapila" Cc: "Sachin Kumar" , "Alvaro Herrera" , "pgsql-hackers@lists.postgresql.org" Subject: Re: Initial Schema Sync for Logical Replication Content-Type: multipart/alternative; boundary=66bca0f0d7424f7490ac2c4cc3a49268 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --66bca0f0d7424f7490ac2c4cc3a49268 Content-Type: text/plain On Tue, Mar 21, 2023, at 8:18 AM, Amit Kapila wrote: > Now, how do we avoid these problems even if we have our own version of > functionality similar to pg_dump for selected objects? I guess we will > face similar problems. If so, we may need to deny schema sync in any > such case. There are 2 approaches for initial DDL synchronization: 1) generate the DDL command on the publisher, stream it and apply it as-is on the subscriber; 2) generate a DDL representation (JSON, for example) on the publisher, stream it, transform it into a DDL command on subscriber and apply it. The option (1) is simpler and faster than option (2) because it does not require an additional step (transformation). However, option (2) is more flexible than option (1) because it allow you to create a DDL command even if a feature was removed from the subscriber and the publisher version is less than the subscriber version or a feature was added to the publisher and the publisher version is greater than the subscriber version. Of course there are exceptions and it should forbid the transformation (in this case, it can be controlled by the protocol version -- LOGICALREP_PROTO_FOOBAR_VERSION_NUM). A decision must be made: simple/restrict vs complex/flexible. One of the main use cases for logical replication is migration (X -> Y where X < Y). Postgres generally does not remove features but it might happen (such as WITH OIDS syntax) and it would break the DDL replication (option 1). In the downgrade case (X -> Y where X > Y), it might break the DDL replication if a new syntax is introduced in X. Having said that, IMO option (1) is fragile if we want to support DDL replication between different Postgres versions. It might eventually work but there is no guarantee. Per discussion [1], I think if we agree that the Alvaro's DDL deparse patch is the way to go with DDL replication, it seems wise that it should be used for initial DDL synchronization as well. [1] https://www.postgresql.org/message-id/CAA4eK1%2Bw_dFytBiv3RxbOL76_noMzmX0QGTc8uS%3Dbc2WaPVoow%40mail.gmail.com -- Euler Taveira EDB https://www.enterprisedb.com/ --66bca0f0d7424f7490ac2c4cc3a49268 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Tue, Mar 21,= 2023, at 8:18 AM, Amit Kapila wrote:
Now, how do we avoid these problems even if w= e have our own version of
functionality similar to pg_dump= for selected objects? I guess we will
face similar proble= ms. If so, we may need to deny schema sync in any
such cas= e.
There are 2 approaches for initial DDL syn= chronization:

1) generate the DDL command o= n the publisher, stream it and apply it as-is on
the subsc= riber;
2) generate a DDL representation (JSON, for example= ) on the publisher, stream
it, transform it into a DDL com= mand on subscriber and apply it.

The option= (1) is simpler and faster than option (2) because it does not
=
require an additional step (transformation). However, option (2) is= more
flexible than option (1) because it allow you to cre= ate a DDL command even if a
feature was removed from the s= ubscriber and the publisher version is less than
the subsc= riber version or a feature was added to the publisher and the
<= div>publisher version is greater than the subscriber version. Of course = there are
exceptions and it should forbid the transformati= on (in this case, it can be
controlled by the protocol ver= sion -- LOGICALREP_PROTO_FOOBAR_VERSION_NUM). A
decision m= ust be made: simple/restrict vs complex/flexible.

One of the main use cases for logical replication is migration (X= -> Y where X
< Y). Postgres generally does not remo= ve features but it might happen (such as
WITH OIDS syntax)= and it would break the DDL replication (option 1). In the
downgrade case (X -> Y where X > Y), it might break the DDL repli= cation if a
new syntax is introduced in X. Having said tha= t, IMO option (1) is fragile if
we want to support DDL rep= lication between different Postgres versions. It
might eve= ntually work but there is no guarantee.

Per= discussion [1], I think if we agree that the Alvaro's DDL deparse patch= is
the way to go with DDL replication, it seems wise that= it should be used for
initial DDL synchronization as well= .





--
Eul= er Taveira

--66bca0f0d7424f7490ac2c4cc3a49268--