Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgtAh-008Uou-EG for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 21:14:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgtAe-002L0P-Pe for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 21:14:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgtAe-002L0H-Gt for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 21:14:57 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgtAc-002bo8-4V for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 21:14:56 +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 423LEnS53396248; Sun, 3 Mar 2024 16:14:49 -0500 From: Tom Lane To: Alvaro Herrera cc: pgsql-hackers@lists.postgresql.org, Dilip Kumar Subject: Re: pgsql: Improve performance of subsystems on top of SLRU In-reply-to: <202403031429.zvfh7chvuk24@alvherre.pgsql> References: <202403031429.zvfh7chvuk24@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Sun, 03 Mar 2024 15:29:22 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3396246.1709500489.1@sss.pgh.pa.us> Date: Sun, 03 Mar 2024 16:14:49 -0500 Message-ID: <3396247.1709500489@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > And I think it's correct that this is somewhat bogus, or at least > confusing: the only way to have control back here on line 1371 after > having executed once is via the "goto retry" line below; and there we > release "prevlock" and set it to NULL beforehand, so it's impossible for > prevlock to be NULL. Looking closer I think this code is all confused, > so I suggest to rework it as shown in the attached patch. This is certainly simpler, but I notice that it holds the current LWLock across the line ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember)); where the old code did not. Could the palloc take long enough that holding the lock is bad? Also, with this coding the "lock = NULL;" assignment just before "goto retry" is a dead store. Not sure if Coverity or other static analyzers would whine about that. regards, tom lane