pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Drouvot, Bertrand <bertranddrouvot.pg@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: Add a new BGWORKER_BYPASS_ROLELOGINCHECK flag
Date: Mon, 09 Oct 2023 12:20:18 -0400
Message-ID: <159529.1696868418@sss.pgh.pa.us> (raw)
In-Reply-To: <ZSPJ0dKz4fdjFs5n@paquier.xyz>
References: <566c1686-c80b-4d4a-b496-b00ac428a095@gmail.com>
	<ZR0EEUyWA1Nuz6CK@paquier.xyz>
	<83f72bb9-f3cf-4344-8d4d-45e128813d58@gmail.com>
	<ZR5FRByOl2y8dORo@paquier.xyz>
	<26e7cd6a-6dd1-4b08-975b-62603eeb6f3f@gmail.com>
	<CALj2ACUJf8ftjiTiNfuVKTvUM3N++dWKnhBOg1EJ29CwoTkXew@mail.gmail.com>
	<ZR9QJrNJ8lJDZ41P@paquier.xyz>
	<ZR-pSNRTY2izuNdg@paquier.xyz>
	<ZR_AESc5tptmpP9t@paquier.xyz>
	<3365937.1696801735@sss.pgh.pa.us>
	<ZSPJ0dKz4fdjFs5n@paquier.xyz>

Michael Paquier <michael@paquier.xyz> 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





view thread (41+ messages)  latest in thread

Message-ID: <159529.1696868418@sss.pgh.pa.us>
Permalink:  ../159529.1696868418@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/159529.1696868418@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, bharath.rupireddyforpostgres@gmail.com, bertranddrouvot.pg@gmail.com, andres@anarazel.de
  Subject: Re: Add a new BGWORKER_BYPASS_ROLELOGINCHECK flag
  In-Reply-To: <159529.1696868418@sss.pgh.pa.us>
  References: <566c1686-c80b-4d4a-b496-b00ac428a095@gmail.com> <ZR0EEUyWA1Nuz6CK@paquier.xyz> <83f72bb9-f3cf-4344-8d4d-45e128813d58@gmail.com> <ZR5FRByOl2y8dORo@paquier.xyz> <26e7cd6a-6dd1-4b08-975b-62603eeb6f3f@gmail.com> <CALj2ACUJf8ftjiTiNfuVKTvUM3N++dWKnhBOg1EJ29CwoTkXew@mail.gmail.com> <ZR9QJrNJ8lJDZ41P@paquier.xyz> <ZR-pSNRTY2izuNdg@paquier.xyz> <ZR_AESc5tptmpP9t@paquier.xyz> <3365937.1696801735@sss.pgh.pa.us> <ZSPJ0dKz4fdjFs5n@paquier.xyz> <159529.1696868418@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox