pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: pgstat: add/extend tests for resetting various kinds of stats.
Date: Fri, 16 Sep 2022 11:39:04 -0700
Message-ID: <20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de> (raw)
In-Reply-To: <3428246.1663271992@sss.pgh.pa.us>
References: <E1ncazy-000nql-Sq@gemulon.postgresql.org>
	<3428246.1663271992@sss.pgh.pa.us>

Hi,

On 2022-09-15 15:59:52 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > pgstat: add/extend tests for resetting various kinds of stats.
> 
> crake just failed [1] with what appears to be a race condition in
> a test case added by this commit:
> 
> diff -U3 /home/andrew/bf/root/HEAD/pgsql/src/test/regress/expected/stats.out /home/andrew/bf/root/HEAD/pgsql.build/src/test/recovery/tmp_check/results/stats.out
> --- /home/andrew/bf/root/HEAD/pgsql/src/test/regress/expected/stats.out	2022-07-18 13:32:25.155847949 -0400
> +++ /home/andrew/bf/root/HEAD/pgsql.build/src/test/recovery/tmp_check/results/stats.out	2022-09-15 12:44:10.022975164 -0400
> @@ -563,7 +563,7 @@
>  SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database());
>   ?column? 
>  ----------
> - t
> + f
>  (1 row)
>  
>  -- Test pg_stat_bgwriter checkpointer-related stats, together with pg_stat_wal
> 
> It seems likely to me that the n_sessions increment hasn't made it to shared
> memory because some background process happened to have a lock on the stats
> entry when we tried.  Don't we need a pg_stat_force_next_flush() call before
> trying to inspect the sessions count?

Indeed. Pushed a fix. To see if there are other omissions, I made
pgstat_report_stat() never flush stats unless force is passed in. No other
failures.


> BTW, the header comment for pgstat_report_stat is badly in need of
> copy-editing.

Hm - you're talking about this sentence?

   ... Callers can use the returned time to set up
 * a timeout after which to call pgstat_report_stat(true), but are not
 * required to to do so.

Reads awkward. I'm struggling with the english language trying to improve it
:(.

"Callers can, but are not required to, use the returned time to set up a
timer, whose expiration should trigger a call to pgstat_report_stat(true)."?

Greetings,

Andres Freund





view thread (5+ messages)  latest in thread

Message-ID: <20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de>
Permalink:  ../20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de/
Also on:    postgresql.org/message-id/20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, tgl@sss.pgh.pa.us
  Subject: Re: pgsql: pgstat: add/extend tests for resetting various kinds of stats.
  In-Reply-To: <20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de>
  References: <E1ncazy-000nql-Sq@gemulon.postgresql.org> <3428246.1663271992@sss.pgh.pa.us> <20220916183904.sss3vsau5tfgtx56@awork3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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