From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Split pgstat_bestart() into three different routines |
Date: | 2025-03-04 05:12:39 |
Message-ID: | E1tpKa7-000h90-2i@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Split pgstat_bestart() into three different routines
pgstat_bestart(), used post-authentication to set up a backend entry
in the PgBackendStatus array, so as its data becomes visible in
pg_stat_activity and related catalogs, has its logic divided into three
routines with this commit, called in order at different steps of the
backend initialization:
* pgstat_bestart_initial() sets up the backend entry with a minimal
amount of information, reporting it with a new BackendState called
STATE_STARTING while waiting for backend initialization and client
authentication to complete. The main benefit that this offers is
observability, so as it is possible to monitor the backend activity
during authentication. This step happens earlier than in the logic
prior to this commit. pgstat_beinit() happens earlier as well, before
authentication.
* pgstat_bestart_security() reports the SSL/GSS status of the
connection, once authentication completes. Auxiliary processes, for
example, do not need to call this step, hence it is optional. This
step is called after performing authentication, same as previously.
* pgstat_bestart_final() reports the user and database IDs, takes the
entry out of STATE_STARTING, and reports its application_name. This is
called as the last step of the three, once authentication completes.
An injection point is added, with a test checking that the "starting"
phase of a backend entry is visible in pg_stat_activity. Some follow-up
patches are planned to take advantage of this refactoring with more
information provided in backend entries during authentication (LDAP
hanging was a problem for the author, initially).
Author: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Discussion: https://postgr.es/m/CAOYmi+=60deN20WDyCoHCiecgivJxr=98s7s7-C8SkXwrCfHXg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c76db55c9085d0b7984ea337576e45a7d1268b97
Modified Files
--------------
doc/src/sgml/monitoring.sgml | 6 +
src/backend/postmaster/auxprocess.c | 3 +-
src/backend/utils/activity/backend_status.c | 210 ++++++++++++++++++----------
src/backend/utils/adt/pgstatfuncs.c | 3 +
src/backend/utils/init/postinit.c | 40 ++++--
src/include/utils/backend_status.h | 5 +-
src/test/authentication/Makefile | 4 +
src/test/authentication/meson.build | 4 +
src/test/authentication/t/007_pre_auth.pl | 81 +++++++++++
9 files changed, 272 insertions(+), 84 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2025-03-04 06:00:20 | pgsql: ecpg: Add TAP test for the ecpg command. |
Previous Message | Michael Paquier | 2025-03-04 01:54:01 | pgsql: Add more assertions in palloc0() and palloc_extended() |