pg_stat_reset_slru(name) doesn't seem to work as documented

Started by torikoshiaover 6 years ago4 messageshackers
Jump to latest
#1torikoshia
atorik@gmail.com

Hi,

When I tried to reset a counter in pg_stat_slru using
pg_stat_reset_slru(name),
not only the specified counter but all the counters were reset.

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 3 | 0 | 0 | 3 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
clog | 0 | 56 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
(snip)

postgres=# SELECT pg_stat_reset_slru('clog');

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
clog | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:37:02.525006+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
(snip)

Attached a patch.

Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION

Attachments:

fix_param_specified_pg_stat_reset_slru_v1.patchapplication/x-patch; name=fix_param_specified_pg_stat_reset_slru_v1.patchDownload+0-2
#2Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: torikoshia (#1)
Re: pg_stat_reset_slru(name) doesn't seem to work as documented

On Fri, May 01, 2020 at 07:10:23PM +0900, Atsushi Torikoshi wrote:

Hi,

When I tried to reset a counter in pg_stat_slru using
pg_stat_reset_slru(name),
not only the specified counter but all the counters were reset.

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 3 | 0 | 0 | 3 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
clog | 0 | 56 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
(snip)

postgres=# SELECT pg_stat_reset_slru('clog');

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
clog | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:37:02.525006+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
(snip)

Attached a patch.

Yeah, that memset is a left-over from some earlier version of the patch.
Thanks for the report and patch, I'll push this shortly.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#3Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Tomas Vondra (#2)
Re: pg_stat_reset_slru(name) doesn't seem to work as documented

On Sat, May 02, 2020 at 02:27:33PM +0200, Tomas Vondra wrote:

On Fri, May 01, 2020 at 07:10:23PM +0900, Atsushi Torikoshi wrote:

Hi,

When I tried to reset a counter in pg_stat_slru using
pg_stat_reset_slru(name),
not only the specified counter but all the counters were reset.

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 3 | 0 | 0 | 3 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
clog | 0 | 56 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:36:26.073433+09
(snip)

postgres=# SELECT pg_stat_reset_slru('clog');

postgres=# SELECT * FROM pg_stat_slru ;
name | blks_zeroed | blks_hit | blks_read | blks_written |
blks_exists | flushes | truncates | stats_reset

------------------+-------------+----------+-----------+--------------+-------------+---------+-----------+-------------------------------
async | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
clog | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2020-05-01 17:37:02.525006+09
commit_timestamp | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 2000-01-01 09:00:00+09
(snip)

Attached a patch.

Yeah, that memset is a left-over from some earlier version of the patch.
Thanks for the report and patch, I'll push this shortly.

Pushed. Thanks for the report.

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#4torikoshia
atorik@gmail.com
In reply to: Tomas Vondra (#3)
Re: pg_stat_reset_slru(name) doesn't seem to work as documented

On Sat, May 2, 2020 at 11:05 PM Tomas Vondra <tomas.vondra@2ndquadrant.com>
wrote

Pushed. Thanks for the report.

Thanks!

--
Atsushi Torikoshi