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 1rX1UA-008MFY-NS for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Feb 2024 16:06:19 +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 1rX1U9-00EW8y-Ms for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Feb 2024 16:06:17 +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 1rX1SN-00ETKe-9A for pgsql-bugs@lists.postgresql.org; Mon, 05 Feb 2024 16:04:27 +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 1rX1SG-005bfx-V5 for pgsql-bugs@lists.postgresql.org; Mon, 05 Feb 2024 16:04:26 +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 415G4CnB123078; Mon, 5 Feb 2024 11:04:12 -0500 From: Tom Lane To: dafoer_x@163.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18331: Why is the session lock (DEFAULT_LOCKMETHOD) not automatically released during process exit? In-reply-to: <18331-b44b290d8d84d690@postgresql.org> References: <18331-b44b290d8d84d690@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 05 Feb 2024 07:28:53 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <123076.1707149052.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 05 Feb 2024 11:04:12 -0500 Message-ID: <123077.1707149052@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: > The comment for the function LockRelationIdForSession mentions “It will be > removed when UnlockRelationIdForSession() is called, or if an > ereport(ERROR) occurs, or if the backend exits.” > However, the callback function ShutdownPostgres, which is triggered during > process exit, only cleans up locks of type USER_LOCKMETHOD. Is it possible > to automatically clean up session locks of type DEFAULT_LOCKMETHOD? I think you are looking in the wrong place. Normal locks are released in the transaction-ending code. We need the special case in ShutdownPostgres because that's not true for user locks. regards, tom lane