Re: [PATCH] pg_stat_activity: make slow/hanging authentication more visible
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Jacob Champion <jacob.champion@enterprisedb.com>
Cc: Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, Noah Misch <noah@leadboat.com>, Andrew Dunstan <andrew@dunslane.net>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Euler Taveira <euler.taveira@enterprisedb.com>, Daniel Gustafsson <daniel@yesql.se>
Date: 2025-03-06T23:15:38Z
Lists: pgsql-hackers
On Thu, Mar 06, 2025 at 02:25:07PM -0800, Jacob Champion wrote: > On Wed, Mar 5, 2025 at 8:08 PM Michael Paquier <michael@paquier.xyz> wrote: >> + WHERE state = 'starting' and wait_event = 'init-pre-auth';}); > > Did you have thoughts on expanding the check to backend_type [1]? > >> + # Give up. The output of the last attempt is logged by query(), >> + # so no need to do anything here. >> + return 0; > > One of my primary complaints about the poll_query_until() > implementation is that "giving up" in this case means continuing to > run pieces of the test that have no business running after a timeout, > and increasing the log noise after a failure. I'm not sure how loudly > to complain in this particular case, since I know we use it > elsewhere... Indeed. The existing poll_query_until() is a bit more reliable in terms of error handling, even with a very low PG_TEST_TIMEOUT_DEFAULT. A second thing that was bugging me on a second lookup this morning is how we should handle error cases. A background psql process depends on what the caller defines for ON_ERROR_STOP. In the case of this test, we're OK to fail immediately because we expect the queries to always work. I'm not sure if this is fine by default, especially if callers of this routine expect to have the same properties as poll_query_until() in Cluster.pm. They would not, because a BackgroundPsql is an entire different object, except if given options when staring psql to act like that. I have applied the simplest patch for now, to silence the failures in the CI, and included your suggestion to add a check on the backend_type for the extra safety it offers. I'd like the addition of the poll_query_until() in the long-term, but I'm really not sure if the semantics would be right this way under a background psql. In the auth 007 test, they would be OK, but it could be surprising if we have other callers that begin relying on it. -- Michael
Commits
-
Fix race condition in TAP test 007_pre_auth
- e2080261cc8c 18.0 landed
-
Split pgstat_bestart() into three different routines
- c76db55c9085 18.0 landed
-
backport: Extend background_psql() to be able to start asynchronously
- 6af51bf05a6a 13.21 landed
- 7c07ab62aeb7 14.18 landed
- c0bc11aebb01 15.13 landed
- 6ab58d506bba 16.9 landed
- 49b6f4a02b23 17.5 landed
-
backport: Improve handling of empty query results in BackgroundPsql
- 3c562b58c20e 13.21 landed
- 3170aece14b8 14.18 landed
- f4b08ccb4ec8 15.13 landed
- fbfd38662f72 16.9 landed
- 31a242e90c88 17.5 landed
-
Improve handling of empty query results in BackgroundPsql::query()
- 70291a3c66ec 18.0 landed
-
Extend Cluster.pm's background_psql() to be able to start asynchronously
- ba08edb06545 18.0 landed
-
dblink: Replace WAIT_EVENT_EXTENSION with custom wait events
- c789f0f6cc5d 17.0 cited