mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
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
This commit is contained in:
parent
b759bb6714
commit
885826f95d
@ -560,6 +560,12 @@ DROP TABLE prevstats;
|
|||||||
-- Test that sessions is incremented when a new session is started in pg_stat_database
|
-- Test that sessions is incremented when a new session is started in pg_stat_database
|
||||||
SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
||||||
\c
|
\c
|
||||||
|
SELECT pg_stat_force_next_flush();
|
||||||
|
pg_stat_force_next_flush
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database());
|
SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database());
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
|
@ -294,6 +294,7 @@ DROP TABLE prevstats;
|
|||||||
-- Test that sessions is incremented when a new session is started in pg_stat_database
|
-- Test that sessions is incremented when a new session is started in pg_stat_database
|
||||||
SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
||||||
\c
|
\c
|
||||||
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database());
|
SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database());
|
||||||
|
|
||||||
-- Test pg_stat_bgwriter checkpointer-related stats, together with pg_stat_wal
|
-- Test pg_stat_bgwriter checkpointer-related stats, together with pg_stat_wal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user