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 1my1A6-0006vN-8J for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 00:31:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1my1A3-0006Qh-Ht for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 00:31:47 +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 1my1A2-0006QX-BR for pgsql-hackers@lists.postgresql.org; Fri, 17 Dec 2021 00:31:47 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1my19x-00019c-Kz for pgsql-hackers@lists.postgresql.org; Fri, 17 Dec 2021 00:31:44 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 716995C00EC; Thu, 16 Dec 2021 19:31:40 -0500 (EST) Received: from imap49 ([10.202.2.99]) by compute5.internal (MEProxy); Thu, 16 Dec 2021 19:31:40 -0500 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=fm3; bh=A0sUUvqipUcM1LaZDATFQQUfkUpGnMW 7Jt+r4GYmRbQ=; b=TQzxGt8hEWx4f4zfko7LQ6uOCmb6mGjm5SX99ZCLijN8UmC JLRkMgSRh7nAVRrt/o6BBq8nRZ8l6ZVBUw/AeBoLghywcfB+cYcCnyke2vIpxK35 s2Sh+/SPLVu2tIGZia7F4aUDDKN7EKnC1GX0E8FKo4/AsO08dH6rve8xGaRy7c9A B5WAsLhoaN9J4+AIZwiHDWUPfIegvxI1gLH57gPfBG0n2kx3CGUxi6H95rEQiXnU HYgezxczsmUuZ8PqcnzDaBKqiIw50rEAEQ9+EasMWZUyZcQy89KC4JJHoifgdYax 9A1IPmYf2eg5R4M6mUrjNtmrnB3X9YQquxcEXSg== 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=fm1; bh=A0sUUv qipUcM1LaZDATFQQUfkUpGnMW7Jt+r4GYmRbQ=; b=Ylam5qne0gPsXxE8CKQJp4 9RQAjMlxLtqW4mvv+uOmjFRVh6oHSz67sRp7sXRE6XZP+lCvUoc61Dt3S8AfZLvW Calb9ELwQzlFuq58H9qt2OhAG7oa2kbK+q/DYjU3m+pT5M+qDj9jUftIt0QR4f5/ aRZF1CkX3K9AoGJg04jD0Ueanp9kFfYCQj7ab4omy3mbjksK6WEPFh0ou6owxFom Dw3AE8VFYMDysTU9efMerGcjNckznPRTAqpLu5YCZgN3XFDD76I80nAUYYU7eErz /N/0V9/+A0mqBrIhe5f1KevEBaOkeImxeeyc4aonAxGnLCyiIXtHikUTSAMHNR0Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrleehgddvudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsegrtderreerredtnecuhfhrohhmpedfgfhulhgv rhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrhhtohdrtghomheqnecuggftrf grthhtvghrnhepjeethfeuvdfgffdtteevudeftdejueffkeelveekhfevkeegleefhfej hedtjeegnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuhhlvghrsegvuhhl vghrthhordgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 95C96F60074; Thu, 16 Dec 2021 19:31:39 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4524-g5e5d2efdba-fm-20211214.001-g5e5d2efd Mime-Version: 1.0 Message-Id: <41e5697a-b7eb-45d7-9f7b-d802d3fdbcf6@www.fastmail.com> In-Reply-To: References: <202112161808.lxanl3r7skol@alvherre.pgsql> Date: Thu, 16 Dec 2021 21:31:15 -0300 From: "Euler Taveira" To: "Michael Paquier" , "Alvaro Herrera" Cc: "Ashutosh Bapat" , "wangw.fnst@fujitsu.com" , "pgsql-hackers@lists.postgresql.org" , "Andres Freund" Subject: Re: Confused comment about drop replica identity index Content-Type: multipart/alternative; boundary=1bab8af00296442882b5f1f8ca71ea5e List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --1bab8af00296442882b5f1f8ca71ea5e Content-Type: text/plain On Thu, Dec 16, 2021, at 8:55 PM, Michael Paquier wrote: > On Thu, Dec 16, 2021 at 03:08:46PM -0300, Alvaro Herrera wrote: > > Hmm, so if a table has REPLICA IDENTITY INDEX and there is a publication > > with an explicit column list, then we need to forbid the DROP INDEX for > > that index. > > Hmm. I have not followed this thread very closely. > > > I wonder why don't we just forbid DROP INDEX of an index that's been > > defined as replica identity. It seems quite silly an operation to > > allow. It would avoid pilot errors. > The commit logs talk about b23b0f55 here for this code, to ease the > handling of relcache entries for rd_replidindex. 07cacba is the > origin of the logic (see RelationGetIndexList). Andres? > > I don't think that this is really an argument against putting more > restrictions as anything that deals with an index drop, including the > internal ones related to constraints, would need to go through > index_drop(), and new features may want more restrictions in place as > you say. > > Now, I don't see a strong argument in changing this behavior either > (aka I have not looked at what this implies for the new publication > types), and we still need to do something for the comment/docs in > existing branches, anyway. So I would still fix this gap as a first > step, then deal with the rest on HEAD as necessary. > I've never understand the weak dependency between the REPLICA IDENTITY and the index used by it. I'm afraid we will receive complaints about this unexpected behavior (my logical replication setup is broken because I dropped an index) as far as new logical replication features are added. Row filtering imposes some restrictions in UPDATEs and DELETEs (an error message is returned and the replication stops) if a column used in the expression isn't part of the REPLICA IDENTITY anymore. It seems we already have some code in RangeVarCallbackForDropRelation() that deals with a system index error condition. We could save a syscall and provide a test for indisreplident there. If this restriction is undesirable, we should at least document this choice and probably emit a WARNING for DROP INDEX. -- Euler Taveira EDB https://www.enterprisedb.com/ --1bab8af00296442882b5f1f8ca71ea5e Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Thu, Dec 16,= 2021, at 8:55 PM, Michael Paquier wrote:
On Thu, Dec 16, 2021 at 03:08:46PM -0300,= Alvaro Herrera wrote:
> Hmm, so if a table has REPLICA= IDENTITY INDEX and there is a publication
> with an ex= plicit column list, then we need to forbid the DROP INDEX for
<= div>> that index.

Hmm.  I have not = followed this thread very closely.

> I w= onder why don't we just forbid DROP INDEX of an index that's been
> defined as replica identity.  It seems quite silly an = operation to
> allow.
It wou= ld avoid pilot errors.

The commit logs talk about b23b0f55 here for = this code, to ease the
handling of relcache entries for rd= _replidindex.  07cacba is the
origin of the logic (se= e RelationGetIndexList).  Andres?

I do= n't think that this is really an argument against putting more
=
restrictions as anything that deals with an index drop, including t= he
internal ones related to constraints, would need to go = through
index_drop(), and new features may want more restr= ictions in place as
you say.

= Now, I don't see a strong argument in changing this behavior either
<= /div>
(aka I have not looked at what this implies for the new public= ation
types), and we still need to do something for the co= mment/docs in
existing branches, anyway.  So I would = still fix this gap as a first
step, then deal with the res= t on HEAD as necessary.

I've n= ever understand the weak dependency between the REPLICA IDENTITY and the=
index used by it. I'm afraid we will receive complaints a= bout this unexpected
behavior (my logical replication setu= p is broken because I dropped an index) as
far as new logi= cal replication features are added.  Row filtering imposes some
=
restrictions in UPDATEs and DELETEs (an error message is retu= rned and the
replication stops) if a column used in the ex= pression isn't part of the REPLICA
IDENTITY anymore.

It seems we already have some code in RangeVarCa= llbackForDropRelation() that
deals with a system index err= or condition. We could save a syscall and provide
a test f= or indisreplident there.

If this restrictio= n is undesirable, we should at least document this choice and
<= div>probably emit a WARNING for DROP INDEX.


--
Euler Taveira

--1bab8af00296442882b5f1f8ca71ea5e--