Re: BUG #18046: stats collection behaviour change is affecting the usability of information.

From: Hamid Akhtar <hamid(dot)akhtar(at)percona(dot)com>
To: jobinau(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18046: stats collection behaviour change is affecting the usability of information.
Date: 2023-08-04 11:22:55
Message-ID: CANugjhvg-EFPc_1w1o0We8O5mUsd9DMYC6MhPOQeyPwaKFBhNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 1 Aug 2023 at 22:01, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18046
> Logged by: Jobin Augustine
> Email address: jobinau(at)gmail(dot)com
> PostgreSQL version: 15.3
> Operating system: CentOS/RHEL
> Description:
>
> After stats collection changes in PG 15, The behaviour stats_reset
> information is changed. which is adversely affecting the usability of data
> presented in the view.
> ```
> select stats_reset from pg_stat_database;
> ```
> Before PG15, stats_reset was always populated so that the user knows the
> cumulative values presented are of how many days.
> But unfortunately, PG 15 keeps it null unless there is an explicit reset
> (pg_stat_reset). The value goes again null if there is a reset due to a
> crash.
> So on a regular system, the User can't understand the cumulative values
> presented in the view.
>
>
Thank you for the bug report Jobin.

IMHO, this is a valid concern. As per the documentation, the "stats_reset"
column tracks the last time the stats were reset. There is no mention of
this being timestamp for manual reset only.

Internally, the server calls pgstat_reset_after_failure whenever it cannot
find the stats file or if the server is recovering from a crash. In case of
a crash, the stats may no longer be valid. Therefore, internally the stats
are dropped, and a new file is written.

Attach is a fix for PG16 and PG15 that resolves this issue. It ensures that
when the database stats are being written to disk and the stats_reset is
not set, it adds the current timestamp to it. Since a new file is written
at initdb and when the server is recovering from a crash, this works as
expected.

Attachment Content-Type Size
pg16_stat_reset_fix.patch application/octet-stream 905 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2023-08-04 13:22:31 Re: BUG #18049: dynamic_shared_memory_type's value `posix` doesn't have any effect, syscall shm_get executes
Previous Message [Quipsy] Markus Karg 2023-08-04 06:12:55 AW: WHERE column = X AND column = Y will always be zero matching rows