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 1oQ7FU-00012v-2z for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Aug 2022 13:13: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 1oQ7FS-0002bZ-V3 for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Aug 2022 13:13: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 1oQ7FS-0002bP-Mu for pgsql-bugs@lists.postgresql.org; Mon, 22 Aug 2022 13:13:46 +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 1oQ7FP-00008Z-GI for pgsql-bugs@lists.postgresql.org; Mon, 22 Aug 2022 13:13:46 +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 27MDDcrK257678; Mon, 22 Aug 2022 09:13:39 -0400 From: Tom Lane To: ma100@hotmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock In-reply-to: <17591-6ae23a6598b64c4e@postgresql.org> References: <17591-6ae23a6598b64c4e@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 22 Aug 2022 06:23:59 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <257676.1661174018.1@sss.pgh.pa.us> Date: Mon, 22 Aug 2022 09:13:38 -0400 Message-ID: <257677.1661174018@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > in lock.c, we can see code Release lock before return , e.g. > ... > bug we can see some code doesn't release the lock. Does it may cause > deadlock? Transaction cleanup will automatically release all locks (and other resources too). So the places that do a manual release before elog(ERROR) are something of a waste of code space. It might be worth doing that if you're concerned about holding the lock for the minimum possible amount of time; but usually that's only a consideration for very heavily-contended spinlocks or LWLocks. regards, tom lane