Re: [PATCH] pg_stat_activity: make slow/hanging authentication more visible
Jacob Champion <jacob.champion@enterprisedb.com>
From: Jacob Champion <jacob.champion@enterprisedb.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>,
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>
Date: 2024-11-08T00:38:45Z
Lists: pgsql-hackers
On Thu, Nov 7, 2024 at 2:56 PM Andres Freund <andres@anarazel.de> wrote: > It does actually make things harder - what if somebody added a > pgstat_report_activity() somewhere between the call? It would suddenly get > lost after the second "initialization". Actually, the proposed patch already > has weird, externally visible, consequences - the application name is set, > then suddenly becomes unset, then is set again. Oh... I think that alone is enough to change my mind; I neglected the effects of that little pgstat_report_appname() stinger... > Additionally PGSTAT_BEGIN_WRITE_ACTIVITY() would already happen twice if you > initialize twice... Sure. I was just trying not to introduce that to _all_ backend code paths, but it sounds like that's not a concern. (Plus, it turns out to be four calls, due again to the application_name reporting...) > That doesn't seem like a reason to just initialize twice to me. If you have > one initialization step that properly initializes everything to a minimal > default state, you then can have granular functions that set up the user, > database, SSL, GSS information separately. I will start work on that then (unless Michael has already beaten me to it?). > But more importantly, because of not having nesting, adding one "coarse" "wait > event" means that anyone adding a wait event at a finer grade suddenly needs > to be aware of all the paths that could lead to the execution of the new > code and change all of them to not use the wait event anymore. It imposes a > tax on measuring actual "out of postgres" wait events. > > One very useful wait event would be for memory allocations that hit the > kernel. Those can take a fairly long time, because they might need to write > dirty buffers to disk before there is enough free memory. Now imagine that we > redefine the system memory allocator (or just postgres') so that all memory > allocations from the kernel use a wait event. Now suddenly all that code that > uses "coarse" wait events suddenly has a *rare* path - because most of the time > we can carve memory out of a larger OS level memory allocation - where wait > events would be nested. Okay, that makes a lot of sense. I will plumb these down as far as I can. Thanks very much! --Jacob
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