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: Michael Paquier <michael@paquier.xyz>
Cc: 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-01T21:47:38Z
Lists: pgsql-hackers
Attachments
- since-v3.diff.txt (text/plain)
- v4-0001-BackgroundPsql-handle-empty-query-results.patch (application/octet-stream) patch v4-0001
- v4-0002-Test-Cluster-let-background_psql-work-asynchronou.patch (application/octet-stream) patch v4-0002
- v4-0003-pgstat-report-in-earlier-with-STATE_STARTING.patch (application/octet-stream) patch v4-0003
- v4-0004-Report-external-auth-calls-as-wait-events.patch (application/octet-stream) patch v4-0004
Hi all, Here's a v4, with a separate wait event for each location. (I could use some eyes on the specific phrasing I've chosen for each one.) On Sun, Sep 1, 2024 at 5:10 PM Michael Paquier <michael@paquier.xyz> wrote: > Could it be more transparent to use a "startup" or > "starting"" state instead that gets also used by pgstat_bestart() in > the case of the patch where !pre_auth? Done. (I've used "starting".) On Mon, Sep 9, 2024 at 10:30 PM Michael Paquier <michael@paquier.xyz> wrote: > A new category would be more adapted. IPC is not adapted because are > not waiting for another server process. Perhaps just use a new > "Authentication" class, as in "The server is waiting for an > authentication operation to complete"? Added a new "Auth" class (to cover both authn and authz during startup), plus documentation. On Wed, Sep 11, 2024 at 4:42 PM Michael Paquier <michael@paquier.xyz> wrote: > Setting up twice the structure as the patch proposes is kind of > a weird concept, but it feels to me that we should split that and set > the fields in the pre-auth step and ignore the irrelevant ones, then > complete the rest in a second step. The more I look at this, the more uneasy I feel about the goal. Best I can tell, the pre-auth step can't ignore irrelevant fields, because they may contain junk from the previous owner of the shared memory. So if we want to optimize, we can only change the second step to skip fields that were already filled in by the pre-auth step. That has its own problems: not every backend type uses the pre-auth step in the current patch. Which means a bunch of backends that don't benefit from the two-step initialization nevertheless have to either do two PGSTAT_BEGIN_WRITE_ACTIVITY() dances in a row, or else we duplicate a bunch of the logic to make sure they maintain the same efficient code path as before. Finally, if we're okay with all of that, future maintainers need to be careful about which fields get copied in the first (preauth) step, the second step, or both. GSS, for example, can be set up during transport negotiation (first step) or authentication (second step), so we have to duplicate the logic there. SSL is currently first-step-only, I think -- but are we sure we want to hardcode the assumption that cert auth can't change any of those parameters after the transport has been established? (I've been brainstorming ways we might use TLS 1.3's post-handshake CertificateRequest, for example.) So before I commit to this path, I just want to double-check that all of the above sounds good and non-controversial. :) -- In the meantime, is anyone willing and able to commit 0001 and/or 0002? Thanks! --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