From 72f92549b64176e00dad433f8486e302eab8e9bd Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 13 Aug 2019 10:56:02 +0900 Subject: [PATCH] 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 410734d7dc..ed0053904e 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 d0367a1c1c..470e165b85 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