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 1qpszc-007QSB-0T for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Oct 2023 16:20:28 +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 1qpszZ-00GZEU-Pm for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Oct 2023 16:20:26 +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 1qpszZ-00GZCX-EU for pgsql-hackers@lists.postgresql.org; Mon, 09 Oct 2023 16:20:26 +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 1qpszX-00175P-QZ for pgsql-hackers@lists.postgresql.org; Mon, 09 Oct 2023 16:20:25 +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 399GKI29159530; Mon, 9 Oct 2023 12:20:18 -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: <566c1686-c80b-4d4a-b496-b00ac428a095@gmail.com> <83f72bb9-f3cf-4344-8d4d-45e128813d58@gmail.com> <26e7cd6a-6dd1-4b08-975b-62603eeb6f3f@gmail.com> <3365937.1696801735@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Mon, 09 Oct 2023 18:37:21 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <159528.1696868418.1@sss.pgh.pa.us> Date: Mon, 09 Oct 2023 12:20:18 -0400 Message-ID: <159529.1696868418@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > Another thing is that we cannot rely on the PID returned by launch() > as it could fail, so $worker3_pid needs to disappear. If we do that, > I'd rather just switch to a specific database for the tests with > ALLOWCONN rather than reuse "mydb" that could have other workers. Right. > The > attached fixes the issue for me. Hmm. This passed a few dozen test cycles on mamba's host, but it seems to me there's still a race condition here: $result = $node->safe_psql('postgres', "SELECT count(*) FROM pg_stat_activity WHERE datname = 'noconndb';"); is($result, '0', 'dynamic bgworker without BYPASS_ALLOWCONN not started'); 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. We could just drop this test, reasoning that the appearance of the error message is sufficient evidence that the right thing happened. (If the failed worker is still around, it won't break the remaining tests AFAICS.) Or we could convert this to a poll_query_until() loop. regards, tom lane