Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteda4ef8

Browse files
committed
stats regression test's wait_for_stats() must check timestamp too.
pg_stat_get_snapshot_timestamp() returns the timestamp seen in the "global"stats file. Because pgstat_write_statsfiles() writes per-DB stats filesbefore the global file (or at least before renaming it into place), thereis a window where the test backend can see all the stats updates thatwait_for_stats() was checking for (all of which come from the per-DB file)but also see the same global stats file it had seen at the start of thetest script. This results in a failure in only the "snapshot_newer" query,as reported by a couple of buildfarm members recently.I suspect that this ought to be back-patched. Commit4e37b3e hasevidently increased the probability of this window getting hit, butit's not apparent why it could not have been hit before. I'll refrainfor the moment though.
1 parentde7cca9 commiteda4ef8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

‎src/test/regress/expected/stats.out

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ declare
3232
updated1 bool;
3333
updated2 bool;
3434
updated3 bool;
35+
updated4 bool;
3536
begin
3637
-- we don't want to wait forever; loop will exit after 30 seconds
3738
for i in 1 .. 300 loop
@@ -55,7 +56,13 @@ begin
5556
SELECT (n_tup_ins > 0) INTO updated3
5657
FROM pg_stat_user_tables WHERE relname='trunc_stats_test4';
5758

58-
exit when updated1 and updated2 and updated3;
59+
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
60+
-- advanced, because that comes from the global stats file which might
61+
-- be older than the per-DB stats file we got the other values from.
62+
SELECT (pr.snap_ts < pg_stat_get_snapshot_timestamp()) INTO updated4
63+
FROM prevstats AS pr;
64+
65+
exit when updated1 and updated2 and updated3 and updated4;
5966

6067
-- wait a little
6168
perform pg_sleep_for('100 milliseconds');

‎src/test/regress/sql/stats.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ declare
3131
updated1 bool;
3232
updated2 bool;
3333
updated3 bool;
34+
updated4 bool;
3435
begin
3536
-- we don't want to wait forever; loop will exit after 30 seconds
3637
for iin1 ..300 loop
@@ -54,7 +55,13 @@ begin
5455
SELECT (n_tup_ins>0) INTO updated3
5556
FROM pg_stat_user_tablesWHERE relname='trunc_stats_test4';
5657

57-
exit when updated1and updated2and updated3;
58+
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
59+
-- advanced, because that comes from the global stats file which might
60+
-- be older than the per-DB stats file we got the other values from.
61+
SELECT (pr.snap_ts< pg_stat_get_snapshot_timestamp()) INTO updated4
62+
FROM prevstatsAS pr;
63+
64+
exit when updated1and updated2and updated3and updated4;
5865

5966
-- wait a little
6067
perform pg_sleep_for('100 milliseconds');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp