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 1jsnty-0005pK-1w for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jul 2020 13:44:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jsntw-0002Sc-Mq for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jul 2020 13:44:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsntw-0002SV-Fp for pgsql-hackers@lists.postgresql.org; Tue, 07 Jul 2020 13:44:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsntu-0002vS-Bn for pgsql-hackers@lists.postgresql.org; Tue, 07 Jul 2020 13:44:47 +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 067DifR41519053; Tue, 7 Jul 2020 09:44:41 -0400 From: Tom Lane To: Bharath Rupireddy cc: Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Issue with cancel_before_shmem_exit while searching to remove a particular registered exit callbacks In-reply-to: References: Comments: In-reply-to Bharath Rupireddy message dated "Tue, 07 Jul 2020 12:05:31 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1519051.1594129481.1@sss.pgh.pa.us> Date: Tue, 07 Jul 2020 09:44:41 -0400 Message-ID: <1519052.1594129481@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bharath Rupireddy writes: > Firstly, pg_start_backup registers nonexclusive_base_backup_cleanup as > on_shmem_exit call back which will > add this function to the before_shmem_exit_list array which is > supposed to be removed on pg_stop_backup > so that we can do the pending cleanup and issue a warning for each > pg_start_backup for which we did not call > the pg_stop backup. Now, I executed a query for which JIT is picked > up, then the the llvm compiler inserts it's > own exit callback i.e. llvm_shutdown at the end of > before_shmem_exit_list array. Now, I executed pg_stop_backup > and call to cancel_before_shmem_exit() is made with the expectation > that the nonexclusive_base_backup_cleanup > callback is removed from before_shmem_exit_list array. I'm of the opinion that the JIT code is abusing this mechanism, and the right thing to do is fix that. The restriction you propose to remove is not just there out of laziness, it's an expectation about what safe use of this mechanism would involve. Un-ordered removal of callbacks seems pretty risky: it would mean that whatever cleanup is needed is not going to be done in LIFO order. regards, tom lane