pgsql: Fix race condition in stats.sql added in 5264add7847

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix race condition in stats.sql added in 5264add7847
Date: 2022-09-16 18:31:35
Message-ID: E1oZG7j-000dmR-ED@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix race condition in stats.sql added in 5264add7847

Very occasionally the stats test failed due to the number of sessions not
being updated yet. Likely this requires that there is contention on the
database's stats entry. Solve this by forcing pending stats to be flushed
before fetching the stats.

I verified that there are no other test failures after making
pgstat_report_stat() only flush stats when force = true.

Per message from Tom Lane and buildfarm member crake.

Discussion: https://postgr.es/m/3428246.1663271992@sss.pgh.pa.us
Backpatch: 15-, where 5264add7847 added the test

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/32914d900f90f7f5238a3856e67f6bc5bf05e1d9

Modified Files
--------------
src/test/regress/expected/stats.out | 6 ++++++
src/test/regress/sql/stats.sql | 1 +
2 files changed, 7 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-09-16 18:39:04 Re: pgsql: pgstat: add/extend tests for resetting various kinds of stats.
Previous Message Tom Lane 2022-09-16 17:23:20 pgsql: Improve plpgsql's ability to handle arguments declared as RECORD