Re: Add pg_accept_connections_start_time() for better uptime calculation
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Robins Tharakan <tharakan@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-04T16:52:33Z
Lists: pgsql-hackers
On 2025/02/16 16:05, Robins Tharakan wrote: > Hi, > > This patch introduces a new function pg_accept_connections_start_time(). > > Currently, pg_postmaster_start_time() is used to determine when the > database started. However, this is not accurate since the postmaster > process can sometimes be up whereas the database is not accepting > connections (for e.g. during child process crash [1], > long crash-recovery etc.) > > This can lead to inaccurate database uptime calculations. > > The new function, pg_accept_connections_start_time(), returns the > time when the database became ready to accept connections. Shouldn't this function also handle the time when the postmaster starts accepting read-only connections? With the patch, it doesn’t seem to cover that case, and it looks like an unexpected timestamp is returned when run on a standby server. Maybe the function should return a record with two columns — one for when the postmaster starts accepting read-only connections and another for normal connections? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION