Add connection establishment duration logging
authorMelanie Plageman <[email protected]>
Wed, 12 Mar 2025 15:33:08 +0000 (11:33 -0400)
committerMelanie Plageman <[email protected]>
Wed, 12 Mar 2025 15:35:27 +0000 (11:35 -0400)
commit18cd15e706ac1f2d6b1c49847a82774ca143352f
tree148f8a5def0fc9ebc2d2ccffa113395b0a4c5aea
parent9219093cab2607f34ac70612a65430a9c519157f
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
12 files changed:
doc/src/sgml/config.sgml
src/backend/postmaster/launch_backend.c
src/backend/postmaster/postmaster.c
src/backend/tcop/backend_startup.c
src/backend/tcop/postgres.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/postgresql.conf.sample
src/include/miscadmin.h
src/include/tcop/backend_startup.h
src/include/utils/timestamp.h
src/test/authentication/t/001_password.pl
src/tools/pgindent/typedefs.list