pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feednot all pg_stat_database fields reset after pg_stat_reset()
6+ messages / 3 participants
[nested] [flat]
* not all pg_stat_database fields reset after pg_stat_reset()
@ 2010-12-11 16:19 tv@fuzzy.cz
2010-12-11 17:31 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: tv@fuzzy.cz @ 2010-12-11 16:19 UTC (permalink / raw)
To: pgsql-bugs
After calling pg_stat_reset, some of the database stats fields are not
actually reset, the value is preserved. I've found the bug is actually in
pgstat_recv_resetcounter function, where only some of the
PgStat_StatDBEntry fields are reset to 0.
This is true for those 6 fields:
n_tuples_returned
n_tuples_fetched
n_tuples_inserted
n_tuples_updated
n_tuples_deleted
last_autovac_time
The docs for "pg_stat_reset()" say "Reset all statistics counters for the
current database to zero (requiret superuser privileges)" and I don't see
any reason why these fields should not be reset, so I guess it's a bug.
See the patch attached (against current dev version).
regards
Tomas
Attachments:
missing-fields.diff (text/plain, 649B) download
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index c3c136a..6510831 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4010,6 +4010,14 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len)
dbentry->n_xact_rollback = 0;
dbentry->n_blocks_fetched = 0;
dbentry->n_blocks_hit = 0;
+
+ dbentry->n_tuples_returned = 0;
+ dbentry->n_tuples_fetched = 0;
+ dbentry->n_tuples_inserted = 0;
+ dbentry->n_tuples_updated = 0;
+ dbentry->n_tuples_deleted = 0;
+
+ dbentry->last_autovac_time = 0;
memset(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: not all pg_stat_database fields reset after pg_stat_reset()
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
@ 2010-12-11 17:31 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-12-11 17:58 ` Re: not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 21:58 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Magnus Hagander <magnus@hagander.net>
0 siblings, 2 replies; 6+ messages in thread
From: Tom Lane @ 2010-12-11 17:31 UTC (permalink / raw)
To: tv@fuzzy.cz; +Cc: pgsql-bugs; Magnus Hagander <magnus@hagander.net>
tv@fuzzy.cz writes:
> After calling pg_stat_reset, some of the database stats fields are not
> actually reset, the value is preserved. I've found the bug is actually in
> pgstat_recv_resetcounter function, where only some of the
> PgStat_StatDBEntry fields are reset to 0.
> This is true for those 6 fields:
> n_tuples_returned
> n_tuples_fetched
> n_tuples_inserted
> n_tuples_updated
> n_tuples_deleted
> last_autovac_time
Hmm. I think that not resetting the n_tuples_xxx fields was simply an
oversight in Magnus' patch that added them,
http://archives.postgresql.org/pgsql-committers/2007-03/msg00144.php
Magnus, was this intentional by any chance?
However, I disagree with resetting last_autovac_time ... that's not a
counter, so there's no particularly good reason to discard its value.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: not all pg_stat_database fields reset after pg_stat_reset()
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 17:31 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-12-11 17:58 ` tv@fuzzy.cz
2010-12-11 18:03 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 6+ messages in thread
From: tv@fuzzy.cz @ 2010-12-11 17:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: tv@fuzzy.cz; pgsql-bugs; Magnus Hagander <magnus@hagander.net>
> However, I disagree with resetting last_autovac_time ... that's not a
> counter, so there's no particularly good reason to discard its value.
Oh yeah, I see. Haven't realized that when writing the patch.
regards
Tomas
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: not all pg_stat_database fields reset after pg_stat_reset()
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 17:31 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
2010-12-11 17:58 ` Re: not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
@ 2010-12-11 18:03 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2010-12-11 18:03 UTC (permalink / raw)
To: tv@fuzzy.cz; +Cc: pgsql-bugs; Magnus Hagander <magnus@hagander.net>
tv@fuzzy.cz writes:
>> However, I disagree with resetting last_autovac_time ... that's not a
>> counter, so there's no particularly good reason to discard its value.
> Oh yeah, I see. Haven't realized that when writing the patch.
... on the other hand, the reset operation is discarding the per-table
last-vacuum times, so maybe discarding the database-level value too is
more consistent. Not sure.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: not all pg_stat_database fields reset after pg_stat_reset()
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 17:31 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-12-11 21:58 ` Magnus Hagander <magnus@hagander.net>
2010-12-12 20:13 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 6+ messages in thread
From: Magnus Hagander @ 2010-12-11 21:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: tv@fuzzy.cz; pgsql-bugs
On Sat, Dec 11, 2010 at 18:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> tv@fuzzy.cz writes:
>> After calling pg_stat_reset, some of the database stats fields are not
>> actually reset, the value is preserved. I've found the bug is actually in
>> pgstat_recv_resetcounter function, where only some of the
>> PgStat_StatDBEntry fields are reset to 0.
>
>> This is true for those 6 fields:
>
>> n_tuples_returned
>> n_tuples_fetched
>> n_tuples_inserted
>> n_tuples_updated
>> n_tuples_deleted
>> last_autovac_time
>
> Hmm. I think that not resetting the n_tuples_xxx fields was simply an
> oversight in Magnus' patch that added them,
> http://archives.postgresql.org/pgsql-committers/2007-03/msg00144.php
> Magnus, was this intentional by any chance?
Nope, not that I can recall. Looks like an oversight.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: not all pg_stat_database fields reset after pg_stat_reset()
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 17:31 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Tom Lane <tgl@sss.pgh.pa.us>
2010-12-11 21:58 ` Re: not all pg_stat_database fields reset after pg_stat_reset() Magnus Hagander <magnus@hagander.net>
@ 2010-12-12 20:13 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2010-12-12 20:13 UTC (permalink / raw)
To: Magnus Hagander <magnus@hagander.net>; +Cc: tv@fuzzy.cz; pgsql-bugs
Magnus Hagander <magnus@hagander.net> writes:
> On Sat, Dec 11, 2010 at 18:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Hmm. I think that not resetting the n_tuples_xxx fields was simply an
>> oversight in Magnus' patch that added them,
>> http://archives.postgresql.org/pgsql-committers/2007-03/msg00144.php
>> Magnus, was this intentional by any chance?
> Nope, not that I can recall. Looks like an oversight.
OK, applied, along with the last_autovac_time reset --- I concluded that
keeping that at the database level wouldn't be consistent, since we're
throwing it away at the table level.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2010-12-12 20:13 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-12-11 16:19 not all pg_stat_database fields reset after pg_stat_reset() tv@fuzzy.cz
2010-12-11 17:31 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-12-11 17:58 ` tv@fuzzy.cz
2010-12-11 18:03 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-12-11 21:58 ` Magnus Hagander <magnus@hagander.net>
2010-12-12 20:13 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox