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
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 50eea2e..51a0279 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -6233,8 +6233,6 @@ pgstat_recv_resetslrucounter(PgStat_MsgResetslrucounter *msg, int len)
int i;
TimestampTz ts = GetCurrentTimestamp();
- memset(&slruStats, 0, sizeof(slruStats));
-
for (i = 0; i < SLRU_NUM_ELEMENTS; i++)
{
/* reset entry with the given index, or all entries (index is -1) */