Re: Add pg_accept_connections_start_time() for better uptime calculation

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Robins Tharakan <tharakan(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add pg_accept_connections_start_time() for better uptime calculation
Date: 2025-03-04 16:52:33
Message-ID: 0661ae3e-0796-4690-a2e6-6ead4347714b@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-03-04 17:00:12 Re: Cannot find a working 64-bit integer type on Illumos
Previous Message Peter Geoghegan 2025-03-04 16:31:01 Re: Next commitfest app release is planned for March 18th