From 5ef3e83ce4ddaa903d2199335b12d4769ef2552f Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Fri, 14 Feb 2020 15:38:51 +0100 Subject: [PATCH] Make multi_utilities test take 2 seconds instead of 20 (#3507) On worker 2 it was waiting for dustbunnies_990001 to be vacuumed/analyzed. This table doesn't actually exist, so that never happend. Now it waits for the correct table and throws an error if it waits more than 10 seconds. --- src/test/regress/expected/multi_utilities.out | 19 +++++++++++++++--- src/test/regress/sql/multi_utilities.sql | 20 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/test/regress/expected/multi_utilities.out b/src/test/regress/expected/multi_utilities.out index 240b63061..c708242c9 100644 --- a/src/test/regress/expected/multi_utilities.out +++ b/src/test/regress/expected/multi_utilities.out @@ -231,6 +231,11 @@ begin -- reset stats snapshot so we can test again perform pg_stat_clear_snapshot(); + -- fail if we reach the end of this loop + if i = 100 then + raise 'Waited too long for analyze/vacuum'; + end if; + end loop; -- report time waited in postmaster log (where it won't change test output) @@ -241,7 +246,7 @@ $$ language plpgsql; \c - - - :worker_2_port CREATE MATERIALIZED VIEW prevcounts AS SELECT analyze_count, vacuum_count FROM pg_stat_user_tables -WHERE relname='dustbunnies_990001'; +WHERE relname='dustbunnies_990002'; -- create function that sleeps until those counters increment create function wait_for_stats() returns void as $$ declare @@ -255,12 +260,12 @@ begin -- check to see if analyze has been updated SELECT (st.analyze_count >= pc.analyze_count + 1) INTO analyze_updated FROM pg_stat_user_tables AS st, pg_class AS cl, prevcounts AS pc - WHERE st.relname='dustbunnies_990001' AND cl.relname='dustbunnies_990001'; + WHERE st.relname='dustbunnies_990002' AND cl.relname='dustbunnies_990002'; -- check to see if vacuum has been updated SELECT (st.vacuum_count >= pc.vacuum_count + 1) INTO vacuum_updated FROM pg_stat_user_tables AS st, pg_class AS cl, prevcounts AS pc - WHERE st.relname='dustbunnies_990001' AND cl.relname='dustbunnies_990001'; + WHERE st.relname='dustbunnies_990002' AND cl.relname='dustbunnies_990002'; exit when analyze_updated or vacuum_updated; @@ -270,6 +275,11 @@ begin -- reset stats snapshot so we can test again perform pg_stat_clear_snapshot(); + -- fail if we reach the end of this loop + if i = 100 then + raise 'Waited too long for analyze/vacuum'; + end if; + end loop; -- report time waited in postmaster log (where it won't change test output) @@ -379,6 +389,9 @@ WHERE tablename = 'dustbunnies_990002' ORDER BY attname; name | 0.166667 (3 rows) +REFRESH MATERIALIZED VIEW prevcounts; +\c - - - :worker_2_port +REFRESH MATERIALIZED VIEW prevcounts; \c - - - :master_port -- verify warning for unqualified VACUUM VACUUM; diff --git a/src/test/regress/sql/multi_utilities.sql b/src/test/regress/sql/multi_utilities.sql index caf2a9895..65c128775 100644 --- a/src/test/regress/sql/multi_utilities.sql +++ b/src/test/regress/sql/multi_utilities.sql @@ -166,6 +166,11 @@ begin -- reset stats snapshot so we can test again perform pg_stat_clear_snapshot(); + -- fail if we reach the end of this loop + if i = 100 then + raise 'Waited too long for analyze/vacuum'; + end if; + end loop; -- report time waited in postmaster log (where it won't change test output) @@ -177,7 +182,7 @@ $$ language plpgsql; \c - - - :worker_2_port CREATE MATERIALIZED VIEW prevcounts AS SELECT analyze_count, vacuum_count FROM pg_stat_user_tables -WHERE relname='dustbunnies_990001'; +WHERE relname='dustbunnies_990002'; -- create function that sleeps until those counters increment create function wait_for_stats() returns void as $$ declare @@ -191,12 +196,12 @@ begin -- check to see if analyze has been updated SELECT (st.analyze_count >= pc.analyze_count + 1) INTO analyze_updated FROM pg_stat_user_tables AS st, pg_class AS cl, prevcounts AS pc - WHERE st.relname='dustbunnies_990001' AND cl.relname='dustbunnies_990001'; + WHERE st.relname='dustbunnies_990002' AND cl.relname='dustbunnies_990002'; -- check to see if vacuum has been updated SELECT (st.vacuum_count >= pc.vacuum_count + 1) INTO vacuum_updated FROM pg_stat_user_tables AS st, pg_class AS cl, prevcounts AS pc - WHERE st.relname='dustbunnies_990001' AND cl.relname='dustbunnies_990001'; + WHERE st.relname='dustbunnies_990002' AND cl.relname='dustbunnies_990002'; exit when analyze_updated or vacuum_updated; @@ -206,6 +211,11 @@ begin -- reset stats snapshot so we can test again perform pg_stat_clear_snapshot(); + -- fail if we reach the end of this loop + if i = 100 then + raise 'Waited too long for analyze/vacuum'; + end if; + end loop; -- report time waited in postmaster log (where it won't change test output) @@ -274,6 +284,10 @@ ANALYZE dustbunnies (name); SELECT attname, null_frac FROM pg_stats WHERE tablename = 'dustbunnies_990002' ORDER BY attname; +REFRESH MATERIALIZED VIEW prevcounts; +\c - - - :worker_2_port +REFRESH MATERIALIZED VIEW prevcounts; + \c - - - :master_port -- verify warning for unqualified VACUUM VACUUM;