Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYv1m-0001Yr-1u for pgsql-committers@arkaria.postgresql.org; Thu, 15 Sep 2022 20:00:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oYv1j-0001zC-Jx for pgsql-committers@arkaria.postgresql.org; Thu, 15 Sep 2022 19:59:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYv1j-0001yw-DF for pgsql-committers@lists.postgresql.org; Thu, 15 Sep 2022 19:59:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYv1f-0004wQ-PW for pgsql-committers@lists.postgresql.org; Thu, 15 Sep 2022 19:59:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28FJxqpM3428247; Thu, 15 Sep 2022 15:59:52 -0400 From: Tom Lane To: Andres Freund cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: pgstat: add/extend tests for resetting various kinds of stats. In-reply-to: References: Comments: In-reply-to Andres Freund message dated "Thu, 07 Apr 2022 22:53:07 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3428245.1663271992.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 15 Sep 2022 15:59:52 -0400 Message-ID: <3428246.1663271992@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund 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.o= ut /home/andrew/bf/root/HEAD/pgsql.build/src/test/recovery/tmp_check/resul= ts/stats.out --- /home/andrew/bf/root/HEAD/pgsql/src/test/regress/expected/stats.out 20= 22-07-18 13:32:25.155847949 -0400 +++ /home/andrew/bf/root/HEAD/pgsql.build/src/test/recovery/tmp_check/resu= lts/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 =3D= (SELECT current_database()); ?column? = ---------- - t + f (1 row) = -- Test pg_stat_bgwriter checkpointer-related stats, together with pg_sta= t_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? BTW, the header comment for pgstat_report_stat is badly in need of copy-editing. regards, tom lane [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Dcrake&dt=3D2= 022-09-15%2016%3A18%3A30