public inbox for [email protected]  
help / color / mirror / Atom feed
From: Melanie Plageman <[email protected]>
To: [email protected]
Subject: pgsql: Add connection establishment duration logging
Date: Wed, 12 Mar 2025 15:37:27 +0000
Message-ID: <[email protected]> (raw)

Add connection establishment duration logging

Add log_connections option 'setup_durations' which logs durations of
several key parts of connection establishment and backend setup.

For an incoming connection, starting from when the postmaster gets a
socket from accept() and ending when the forked child backend is first
ready for query, there are multiple steps that could each take longer
than expected due to external factors. This logging provides visibility
into authentication and fork duration as well as the end-to-end
connection establishment and backend initialization time.

To make this portable, the timings captured in the postmaster (socket
creation time, fork initiation time) are passed through the
BackendStartupData.

Author: Melanie Plageman <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Jacob Champion <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Reviewed-by: Guillaume Lelarge <[email protected]>
Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/18cd15e706ac1f2d6b1c49847a82774ca143352f

Modified Files
--------------
doc/src/sgml/config.sgml                      | 13 ++++++
src/backend/postmaster/launch_backend.c       | 31 +++++++++++++++
src/backend/postmaster/postmaster.c           |  6 +++
src/backend/tcop/backend_startup.c            | 11 ++++++
src/backend/tcop/postgres.c                   | 33 ++++++++++++++++
src/backend/utils/init/postinit.c             |  6 +++
src/backend/utils/misc/postgresql.conf.sample |  2 +-
src/include/miscadmin.h                       |  8 ++++
src/include/tcop/backend_startup.h            | 57 +++++++++++++++++++++++++--
src/include/utils/timestamp.h                 |  9 +++++
src/test/authentication/t/001_password.pl     | 18 ++++++++-
src/tools/pgindent/typedefs.list              |  1 +
12 files changed, 189 insertions(+), 6 deletions(-)



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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Add connection establishment duration logging
  In-Reply-To: <[email protected]>

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

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