Re: BUG #18046: stats collection behaviour change is affecting the usability of information. - Mailing list pgsql-bugs

From Hamid Akhtar
Subject Re: BUG #18046: stats collection behaviour change is affecting the usability of information.
Date
Msg-id CANugjhvg-EFPc_1w1o0We8O5mUsd9DMYC6MhPOQeyPwaKFBhNQ@mail.gmail.com
Whole thread Raw
In response to BUG #18046: stats collection behaviour change is affecting the usability of information.  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18046: stats collection behaviour change is affecting the usability of information.  (Jobin Augustine <jobin.augustine@percona.com>)
List pgsql-bugs


On Tue, 1 Aug 2023 at 22:01, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18046
Logged by:          Jobin Augustine
Email address:      jobinau@gmail.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

pgsql-bugs by date:

Previous
From: "[Quipsy] Markus Karg"
Date:
Subject: AW: WHERE column = X AND column = Y will always be zero matching rows
Next
From: Andrew Dunstan
Date:
Subject: Re: BUG #18049: dynamic_shared_memory_type's value `posix` doesn't have any effect, syscall shm_get executes