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 1rgsSd-008Qpe-Dl for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 20:29:27 +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 1rgsSc-002ECt-1z for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Mar 2024 20:29:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgsPT-0029o7-2r for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 20:26:12 +0000 Received: from fout2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgsPK-002gcn-Fy for pgsql-hackers@lists.postgresql.org; Sun, 03 Mar 2024 20:26:10 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 2534D13800CE; Sun, 3 Mar 2024 15:26:02 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 03 Mar 2024 15:26:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709497562; x= 1709583962; bh=0PexwUKTuFDzzmwBDa7e4PIXtFV9x31t7gSAmYPsHw8=; b=T cn7Gb628zYfbTB0RM0ujezkt0IQ5m8+wXQWVLzwv3iNZUC0IpNpp3o1H0/iJv8th G8qOUL1dJ4/VL9pwde3kD9FKkI7ZY4nFcHbx7sqSHAB6D2KziPqULH86msYf4i8z 7SRNbtVdBWwtLb4iIHi7UTHXMfOVSvey6V1FvGIgyMpx3MhPko7PsVBqECW2gjjv 284wzBvm8KIOWV+5k16OZ0+X1ZtBWT2zEgSTXYng8KQ93UoFDDnHtJG8rUpxZ5Ys ncvRunIhcUH0g5mo/+OhE4LKElH2T2nZjLqIIMw7ny/CG363LgZcBjDGgcdnMjtI nhAkjfSm//xnkpCFWWmHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheehgddufeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehmke erredttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeduleekkefgtd dttedtkefguddvieffleetgeejiefhteehkeevfeettdduvdfhueenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Mar 2024 15:26:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1709476162; bh=zPCMyt5bPs3dq7W22UAG0AWjKIRy8ZsgbvvBB/tsMUA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=RBRlsawYuuopV3jcpGmxutt/msGNO10jDm6zP2yTkivpTw79pCu8ZoDNtaZUyU0b6 oc7kZg0VAIfF58eVuARdfCvIuWuKDz04seJKpLFJRb0A5EJ85fpGAt3vS5thCPtXZw q4vFUMKa0cIEhQK1Osl4WN1YYCmZoGo8LZLep8cq525+V1XnKATZQVKR8PPaZhru8X wT3jWTHeZ4R7ZfKuExANVujGIZhWijlii8wuabOim0UOfpLYbEhcxdpuTbKpG19nD+ jFkzOP7fIR0HfmlSlFf0iYwmG5mc+PxXE6ZNl5ldkI3bMabiCa/cFDTZ1UJwHvy904 p6wZ2QeEw83tA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 06A53D40; Sun, 3 Mar 2024 15:29:22 +0100 (CET) Date: Sun, 3 Mar 2024 15:29:22 +0100 From: Alvaro Herrera To: pgsql-hackers@lists.postgresql.org Cc: Dilip Kumar Subject: Re: pgsql: Improve performance of subsystems on top of SLRU Message-ID: <202403031429.zvfh7chvuk24@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rb5vb6debo3bx6lt" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rb5vb6debo3bx6lt Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Feb-28, Alvaro Herrera wrote: > Improve performance of subsystems on top of SLRU Coverity had the following complaint about this commit: ________________________________________________________________________________________________________ *** CID NNNNNNN: Control flow issues (DEADCODE) /srv/coverity/git/pgsql-git/postgresql/src/backend/access/transam/multixact.c: 1375 in GetMultiXactIdMembers() 1369 * and acquire the lock of the new bank. 1370 */ 1371 lock = SimpleLruGetBankLock(MultiXactOffsetCtl, pageno); 1372 if (lock != prevlock) 1373 { 1374 if (prevlock != NULL) >>> CID 1592913: Control flow issues (DEADCODE) >>> Execution cannot reach this statement: "LWLockRelease(prevlock);". 1375 LWLockRelease(prevlock); 1376 LWLockAcquire(lock, LW_EXCLUSIVE); 1377 prevlock = lock; 1378 } 1379 1380 slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi); 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. I'll have a look at the other places where we use this "prevlock" coding pattern tomorrow. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --rb5vb6debo3bx6lt Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-rework-locking-code-in-GetMultiXactIdMembers.patch"