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 1qq3AF-0080KC-T2 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Oct 2023 03:12:08 +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 1qq3AD-0034Vp-8w for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Oct 2023 03:12:06 +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 1qq3AC-0034Vh-Uf for pgsql-hackers@lists.postgresql.org; Tue, 10 Oct 2023 03:12:05 +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 1qq3AB-001DW9-Af for pgsql-hackers@lists.postgresql.org; Tue, 10 Oct 2023 03:12:05 +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 39A3BwTa240195; Mon, 9 Oct 2023 23:11:58 -0400 From: Tom Lane To: Michael Paquier cc: Bharath Rupireddy , "Drouvot, Bertrand" , PostgreSQL Hackers , Andres Freund Subject: Re: Add a new BGWORKER_BYPASS_ROLELOGINCHECK flag In-reply-to: References: <83f72bb9-f3cf-4344-8d4d-45e128813d58@gmail.com> <26e7cd6a-6dd1-4b08-975b-62603eeb6f3f@gmail.com> <3365937.1696801735@sss.pgh.pa.us> <159529.1696868418@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Tue, 10 Oct 2023 07:37:49 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <240193.1696907518.1@sss.pgh.pa.us> Date: Mon, 09 Oct 2023 23:11:58 -0400 Message-ID: <240194.1696907518@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Mon, Oct 09, 2023 at 12:20:18PM -0400, Tom Lane wrote: >> There will be a window where the worker has logged "database >> "noconndb" is not currently accepting connections" but hasn't yet >> exited, so that conceivably this query could see a positive count. > I don't think that's possible here. The check on datallowconn is done > before a backend calls pgstat_bestart() which would make its backend > entry reported to pg_stat_activity. So there is no window where a > backend would be in pg_stat_activity if this check fails. Ah, right. I complained after seeing that we set MyProc->databaseId before doing CheckMyDatabase, but you're right that it doesn't matter for pg_stat_activity until pgstat_bestart. > Saying that, I'm OK with just dropping this query, as it could also be > possible that one decides that calling pgstat_bestart() before the > datallowconn check is a good idea for a reason or another. Not sure if that's a likely change or not. However, if we're in agreement that this test step isn't buying much, let's just drop it and save the test cycles. regards, tom lane