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 1lejf2-0001UO-Nk for pgsql-hackers@arkaria.postgresql.org; Thu, 06 May 2021 19:27:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lejf0-0000we-2C for pgsql-hackers@arkaria.postgresql.org; Thu, 06 May 2021 19:27:46 +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 1lejez-0000wF-QP for pgsql-hackers@lists.postgresql.org; Thu, 06 May 2021 19:27:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lejes-0004f6-Mh for pgsql-hackers@postgresql.org; Thu, 06 May 2021 19:27:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 146JRTk44175579; Thu, 6 May 2021 15:27:29 -0400 From: Tom Lane To: Andres Freund cc: =?utf-8?B?55uP5LiA?= , pgsql-hackers Subject: Re: use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()` In-reply-to: <20210506190841.sqxci46qamoyb55u@alap3.anarazel.de> References: <20210506190841.sqxci46qamoyb55u@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 06 May 2021 12:08:41 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4175577.1620329249.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 06 May 2021 15:27:29 -0400 Message-ID: <4175578.1620329249@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2021-05-07 00:30:13 +0800, =E7=9B=8F=E4=B8=80 wrote: >> Since we have introduced `pgxactoff` in [941697c3c1ae5d6ee153065adb96e1= e63ee11224](https://github.com/postgres/postgres/commit/941697c3c1ae5d6ee1= 53065adb96e1e63ee11224), and `pgxactoff` is always the index of `proc->pgp= rocno` in `procArray->pgprocnos`. So it seems that we could directly use `= proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`? My though= t is to replace > Sounds like a plan! Do you want to write a patch? > If you do, I think it might be worthwhile to add an only-with-assertions > loop checking that there's no other entry with the same pgprocno in the > dense arrays. Hmm, I can definitely see keeping a check that the selected entry has the right PID and/or pgprocno, but making it search for duplicates seems a bit over the top. The existing code isn't guarding against that, and I don't really see a reason why there's a meaningful risk of it. > Given that the code is new in 14, I wonder if we should cram this > simplification in before beta? +1, seems like a pretty clear missed opportunity in 941697c3c. regards, tom lane