postgres.git / summary / log / commit / refs

commit    fc8c6ae5fdebb8dc39b3d001aa332b80e0945fc2
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Tue Aug 13 01:56:07 2019 +0000
First released in: 13.0, 10.11, 11.6, 12.0

    Fix random regression failure in test case "temp"
    
    This test case could fail because of an incorrect result ordering when
    looking up at pg_class entries.  This commit adds an ORDER BY to the
    culprit query.  The cause of the failure was likely caused by a plan
    switch.  By default, the planner would likely choose an index-only scan
    or an index scan, but even a small change in the startup cost could have
    caused a bitmap heap scan to be chosen, causing the failure.
    
    While on it, switch some filtering quals to a regular expression as per
    an idea of Tom Lane.  As previously shaped, the quals would have
    selected any relations whose name begins with "temp".  And that could
    cause failures if another test running in parallel began to use similar
    relation names.
    
    Per report from buildfarm member anole, though the failure was very
    rare.  This test has been introduced by 319a810, so backpatch down to
    v10.
    
    Discussion: https://postgr.es/m/20190807132422.GC15695@paquier.xyz
    Backpatch-through: 10


src/test/regress/expected/temp.out | 9 +++++---- src/test/regress/sql/temp.sql | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out index aad562791e2..5e089ef0503 100644 --- a/src/test/regress/expected/temp.out +++ b/src/test/regress/expected/temp.out @@ -246,7 +246,7 @@ create temp table temp_parted_oncommit_test2 insert into temp_parted_oncommit_test values (1), (2); commit; -- no relations remain in this case. -select relname from pg_class where relname like 'temp_parted_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_parted_oncommit_test'; relname --------- (0 rows) @@ -273,7 +273,8 @@ select * from temp_parted_oncommit_test; (1 row) -- two relations remain in this case. -select relname from pg_class where relname like 'temp_parted_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' + order by relname; relname ---------------------------- temp_parted_oncommit_test @@ -290,7 +291,7 @@ create temp table temp_inh_oncommit_test1 () insert into temp_inh_oncommit_test1 values (1); commit; -- no relations remain in this case -select relname from pg_class where relname like 'temp_inh_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_inh_oncommit_test'; relname --------- (0 rows) @@ -309,7 +310,7 @@ select * from temp_inh_oncommit_test; (0 rows) -- one relation remains -select relname from pg_class where relname like 'temp_inh_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_inh_oncommit_test'; relname ------------------------ temp_inh_oncommit_test diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql index c14c11444c3..f8d2a285c3c 100644 --- a/src/test/regress/sql/temp.sql +++ b/src/test/regress/sql/temp.sql @@ -192,7 +192,7 @@ create temp table temp_parted_oncommit_test2 insert into temp_parted_oncommit_test values (1), (2); commit; -- no relations remain in this case. -select relname from pg_class where relname like 'temp_parted_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_parted_oncommit_test'; -- Using ON COMMIT DELETE on a partitioned table does not remove -- all rows if partitions preserve their data. begin; @@ -210,7 +210,8 @@ commit; -- preserved. select * from temp_parted_oncommit_test; -- two relations remain in this case. -select relname from pg_class where relname like 'temp_parted_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' + order by relname; drop table temp_parted_oncommit_test; -- Check dependencies between ON COMMIT actions with inheritance trees. @@ -222,7 +223,7 @@ create temp table temp_inh_oncommit_test1 () insert into temp_inh_oncommit_test1 values (1); commit; -- no relations remain in this case -select relname from pg_class where relname like 'temp_inh_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_inh_oncommit_test'; -- Data on the parent is removed, and the child goes away. begin; create temp table temp_inh_oncommit_test (a int) on commit delete rows; @@ -233,7 +234,7 @@ insert into temp_inh_oncommit_test values (1); commit; select * from temp_inh_oncommit_test; -- one relation remains -select relname from pg_class where relname like 'temp_inh_oncommit_test%'; +select relname from pg_class where relname ~ '^temp_inh_oncommit_test'; drop table temp_inh_oncommit_test; -- Tests with two-phase commit [parent: f8d2cdc12c94]