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 1k5IQd-0007F0-KG for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Aug 2020 00:46:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5IQc-0004ci-DK for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Aug 2020 00:46:10 +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 1k5IQc-0004cb-6X for pgsql-hackers@lists.postgresql.org; Tue, 11 Aug 2020 00:46:10 +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 1k5IQa-0007ZM-38 for pgsql-hackers@lists.postgresql.org; Tue, 11 Aug 2020 00:46:09 +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 07B0k2Fa3354160; Mon, 10 Aug 2020 20:46:02 -0400 From: Tom Lane To: Andres Freund cc: Robert Haas , Bharath Rupireddy , PostgreSQL Hackers Subject: Re: Issue with cancel_before_shmem_exit while searching to remove a particular registered exit callbacks In-reply-to: <20200811001102.bwcwmrwgirxyec6i@alap3.anarazel.de> References: <20200807212022.wocdoo2mmzhjsjm3@alap3.anarazel.de> <3195298.1597070661@sss.pgh.pa.us> <3250875.1597088493@sss.pgh.pa.us> <20200811001102.bwcwmrwgirxyec6i@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 10 Aug 2020 17:11:02 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3354158.1597106762.1@sss.pgh.pa.us> Date: Mon, 10 Aug 2020 20:46:02 -0400 Message-ID: <3354159.1597106762@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > I think there's two different aspects here: Having before_shmem_exit(), > and having cancel_before_shmem_exit(). We could just not have the > latter, and instead use a separate list for PG_ENSURE_ERROR_CLEANUP > internally. With the callback for PG_ENSURE_ERROR_CLEANUP calling those > from its private list. There's no other uses of > cancel_before_shmem_exit afaict. It's certainly arguable that PG_ENSURE_ERROR_CLEANUP is a special snowflake and needs to use a separate mechanism. What is not real clear to me is why there are any other callers that must use before_shmem_exit rather than on_shmem_exit --- IOW, except for P_E_E_C's use, I have never been persuaded that the former callback list should exist at all. The expectation for on_shmem_exit is that callbacks correspond to system service modules that are initialized in a particular order, and can safely be torn down in the reverse order. Why can't the existing callers just make even-later entries into that same callback list? regards, tom lane