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 1peRKM-0004am-Os for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Mar 2023 02:02:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1peRKL-00062Q-Gy for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Mar 2023 02:02:17 +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 1peRKJ-00062H-NH for pgsql-hackers@lists.postgresql.org; Tue, 21 Mar 2023 02:02:17 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1peRKE-0000Gy-N3 for pgsql-hackers@lists.postgresql.org; Tue, 21 Mar 2023 02:02:15 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 40FA93200495; Mon, 20 Mar 2023 22:02:04 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute6.internal (MEProxy); Mon, 20 Mar 2023 22:02:04 -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=1679364123; x=1679450523; bh=MY 4TurDG8A7Ik/+lrTtHjNIhAza9ironm63/8pV3oFc=; b=x7Vtj/zBljgoiQ1cY8 lb2Muyn5sa1Tc94LIdc3kVV0rEIVWduov/lWRvWzA8AdIb+sMk7VB8n9k8KREgqd pJLgjk5bmvh8iK6jGCbRs+lBzPHa0TT/qE4Bg50gDwNjd11utl7l7fgbIhBZufeW Y5c3cDis9tB6Dw2PLtEXVsFN6V+Ut1uECVuFsiiQRMfJNNZJcSPi+E4TfWJwQzKv 8WHpsgX0TOuWW9crR22V1VqQLZ7xIckC7wAmhALqjoS2x1pRaJKeInTDef/KyqwD 66jYwJmJYRiLYOUbNCvy0zX9Ggf0vzWUCmFEWgP1khzkezNYhPPDp72+7HbJHa4o /F8A== 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=1679364123; x=1679450523; bh=MY4TurDG8A7Ik /+lrTtHjNIhAza9ironm63/8pV3oFc=; b=BX4FpeLKSxpjZqOOKIeVtDvhDSkFN 2yZq03lYJ/fxM/drJWAyulxLGHVVePnnrtM/Ll7JcWdmKuWBhKpcPfkae4W7nl5J YVvotxiSSTaJSL4V2wzchBMEdOtYMaO2WyWFNgTapY2m62uHU9DvXXhOXoKIaDC8 qcUfv+D2uVoMVblrNUGFwrsPNNUsI/XTRJa5LxRLe3GMqi2NFEsYAqnv1ltKXRvU 3XRbRqQQfOBBceSCh1iClEfSEWT41Btvdunva7FV+ULywz1Vjotw0BB6Su5fMUee 6eYmqDnYUwP+thOhJf+x+j+8qaREpPRDOej9gKS8j7vZksjKFeRUnd7BQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefledgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerredtnecuhfhrohhmpedfgfhu lhgvrhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrhhtohdrtghomheqnecugg ftrfgrthhtvghrnhepgfffjedviedvkedviedvteduieekudeivedthffhuddvteegleet ieffkeeghfdvnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuhhlvghrsegv uhhlvghrthhordgtohhm X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8666515A008E; Mon, 20 Mar 2023 22:02:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-221-gec32977366-fm-20230306.001-gec329773 Mime-Version: 1.0 Message-Id: <22c275cc-a2d5-4cee-ac81-bbb6950248b8@app.fastmail.com> In-Reply-To: References: <20230318120638.3z7usvxwncs47tdy@alvherre.pgsql> Date: Mon, 20 Mar 2023 23:01:32 -0300 From: "Euler Taveira" To: "Kumar, Sachin" , "Alvaro Herrera" Cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: Initial Schema Sync for Logical Replication Content-Type: multipart/alternative; boundary=c1d343a5b3e74326a6ecba9901afee51 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --c1d343a5b3e74326a6ecba9901afee51 Content-Type: text/plain On Mon, Mar 20, 2023, at 10:10 PM, Kumar, Sachin wrote: > > From: Alvaro Herrera > > Subject: RE: [EXTERNAL]Initial Schema Sync for Logical Replication > > On 2023-Mar-15, Kumar, Sachin wrote: > > > > > 1. In CreateSubscription() when we create replication > > > slot(walrcv_create_slot()), should use CRS_EXPORT_SNAPSHOT, So that we > > can use this snapshot later in the pg_dump. > > > > > > 2. Now we can call pg_dump with above snapshot from CreateSubscription. > > > > Overall I'm not on board with the idea that logical replication would depend on > > pg_dump; that seems like it could run into all sorts of trouble (what if calling > > external binaries requires additional security setup? what about pg_hba > > connection requirements? what about max_connections in tight > > circumstances?). > > what if calling external binaries requires additional security setup > I am not sure what kind of security restriction would apply in this case, maybe pg_dump > binary can be changed ? Using pg_dump as part of this implementation is not acceptable because we expect the backend to be decoupled from the client. Besides that, pg_dump provides all table dependencies (such as tablespaces, privileges, security labels, comments); not all dependencies shouldn't be replicated. You should exclude them removing these objects from the TOC before running pg_restore or adding a few pg_dump options to exclude these objects. Another issue is related to different version. Let's say the publisher has a version ahead of the subscriber version, a new table syntax can easily break your logical replication setup. IMO pg_dump doesn't seem like a good solution for initial synchronization. Instead, the backend should provide infrastructure to obtain the required DDL commands for the specific (set of) tables. This can work around the issues from the previous paragraph: * you can selectively choose dependencies; * don't require additional client packages; * don't need to worry about different versions. This infrastructure can also be useful for other use cases such as: * client tools that provide create commands (such as psql, pgAdmin); * other logical replication solutions; * other logical backup solutions. -- Euler Taveira EDB https://www.enterprisedb.com/ --c1d343a5b3e74326a6ecba9901afee51 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Mon, Mar 20,= 2023, at 10:10 PM, Kumar, Sachin wrote:
> From: Alvaro Herrera <alvherre@alvh.no-ip.org>
=
> Subject: RE: [EXTERNAL]Initial Schema Sync for Logical Replica= tion
> On 2023-Mar-15, Kumar, Sachin wrote:

> > 1. In  CreateSubscription()&n= bsp; when we create replication
> > slot(walrcv_crea= te_slot()), should use CRS_EXPORT_SNAPSHOT, So that we
>= ; can use this snapshot later in the pg_dump.
> >
> > 2.  Now we can call pg_dump with above snapsh= ot from CreateSubscription.

> = Overall I'm not on board with the idea that logical replication would de= pend on
> pg_dump; that seems like it could run into al= l sorts of trouble (what if calling
> external binaries= requires additional security setup?  what about pg_hba
> connection requirements? what about max_connections in tight
=
> circumstances?).
> what if calling exte= rnal binaries requires additional security setup
I am not = sure what kind of security restriction would apply in this case, maybe p= g_dump
binary can be changed ? 
Using pg_dump as part of this implementation is not acceptabl= e because we
expect the backend to be decoupled from= the client. Besides that, pg_dump
provides all table depe= ndencies (such as tablespaces, privileges, security
labels= , comments); not all dependencies shouldn't be replicated. You should
exclude them removing these objects from the TOC before runn= ing pg_restore or
adding a few pg_dump options to exclude = these objects. Another issue is related
to different versi= on. Let's say the publisher has a version ahead of the
sub= scriber version, a new table syntax can easily break your logical
replication setup. IMO pg_dump doesn't seem like a good solution= for initial
synchronization.

Instead, the backend should provide infrastructure to obtain the r= equired DDL
commands for the specific (set of) tables. Thi= s can work around the issues from
the previous paragraph:<= br>

* you can selectively choose dependencies;<= br>
* don't require additional client packages;
= * don't need to worry about different versions.

=
This infrastructure can also be useful for other use cases such as:=

* client tools that provide create command= s (such as psql, pgAdmin);
* other logical replication sol= utions;
* other logical backup solutions.
<= div>

--
Euler Taveira

--c1d343a5b3e74326a6ecba9901afee51--