Fix failures with cross-version pg_upgrade tests
authorMichael Paquier <michael@paquier.xyz>
Wed, 10 Dec 2025 03:46:45 +0000 (12:46 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 10 Dec 2025 03:46:45 +0000 (12:46 +0900)
Buildfarm members skimmer and crake have reported that pg_upgrade
running from v18 fails due to the changes of d52c24b0f808, with the
expectations that the objects removed in the test module
injection_points should still be present post upgrades, but the test
module does not have them anymore.

The origin of the issue is that the following test modules depend on
injection_points, but they do not drop the extension once the tests
finish, leaving its traces in the dumps used for the upgrades:
- gin, down to v17
- typcache, down to v18
- nbtree, HEAD-only
Test modules have no upgrade requirements, as they are used only for..
Tests, so there is no point in keeping them around.

An alternative solution would be to drop the databases created by these
modules in AdjustUpgrade.pm, but the solution of this commit to drop the
extension is simpler.  Note that there would be a catch if using a
solution based on AdjustUpgrade.pm as the database name used for the
test runs differs between configure and meson:
- configure relies on USE_MODULE_DB for the database name unicity, that
would build a database name based on the *first* entry of REGRESS, that
lists all the SQL tests.
- meson relies on a "name" field.

For example, for the test module "gin", the regression database is named
"regression_gin" under meson, while it is more complex for configure, as
of "contrib_regression_gin_incomplete_splits".  So a AdjustUpgrade.pm
would need a set of DROP DATABASE IF EXISTS to solve this issue, to cope
with each build system.

The failure has been caused by d52c24b0f808, and the problem can happen
with upgrade dumps from v17 and v18 to HEAD.  This problem is not
currently reachable in the back-branches, but it could be possible that
a future change in injection_points in stable branches invalidates this
theory, so this commit is applied down to v17 in the test modules that
matter.

Per discussion with Tom Lane and Heikki Linnakangas.

Discussion: https://postgr.es/m/2899652.1765167313@sss.pgh.pa.us
Backpatch-through: 17

src/test/modules/gin/expected/gin_incomplete_splits.out
src/test/modules/gin/sql/gin_incomplete_splits.sql
src/test/modules/nbtree/expected/nbtree_half_dead_pages.out
src/test/modules/nbtree/expected/nbtree_incomplete_splits.out
src/test/modules/nbtree/sql/nbtree_half_dead_pages.sql
src/test/modules/nbtree/sql/nbtree_incomplete_splits.sql
src/test/modules/typcache/expected/typcache_rel_type_cache.out
src/test/modules/typcache/sql/typcache_rel_type_cache.sql

index 15574e547ac9a317251d7069deb8364c583d3df8..0f3ac9a04660bf11709722043dd01d7fc6e8bddc 100644 (file)
@@ -192,3 +192,4 @@ SELECT injection_points_detach('gin-finish-incomplete-split');
  
 (1 row)
 
+drop extension injection_points;
index ebf0f620f0c1a195a017f58ec9241563e07ab4a0..d451257c2753fbd851c13872d18dd882d6da1e73 100644 (file)
@@ -148,3 +148,5 @@ select insert_n(:next_i, 10) as next_i
 select verify(:next_i);
 
 SELECT injection_points_detach('gin-finish-incomplete-split');
+
+drop extension injection_points;
index e94f016696d980be9a931f104900403ad037d100..c435af7a4a5ef8b6f47d1f86039faf6cb0efa3e5 100644 (file)
@@ -83,3 +83,5 @@ select bt_index_parent_check('nbtree_half_dead_pages_id_idx'::regclass, true, tr
  
 (1 row)
 
+drop extension amcheck;
+drop extension injection_points;
index 161eb3cbfa81e3d5b31a405a2adc9802fae8609c..00168c6ebb88a89bd0097fef9bfed405999c500f 100644 (file)
@@ -184,3 +184,5 @@ SELECT injection_points_detach('nbtree-finish-incomplete-split');
  
 (1 row)
 
+drop extension amcheck;
+drop extension injection_points;
index fd279b87e0e7ddeb9d67031d07f7bde6bd5e78c4..b39cf275557e299ebe852aec786b1ff970857816 100644 (file)
@@ -46,3 +46,6 @@ select bt_index_parent_check('nbtree_half_dead_pages_id_idx'::regclass, true, tr
 vacuum nbtree_half_dead_pages;
 select * from nbtree_half_dead_pages where id > 99998 and id < 120002;
 select bt_index_parent_check('nbtree_half_dead_pages_id_idx'::regclass, true, true);
+
+drop extension amcheck;
+drop extension injection_points;
index f6b22786d37d025849058d281035c3de3c470b2b..23a112a074bee75b8cf73a6c9f53b19c938b31cd 100644 (file)
@@ -139,3 +139,6 @@ select insert_n(:next_i, 10) as next_i
 select verify(:next_i);
 
 SELECT injection_points_detach('nbtree-finish-incomplete-split');
+
+drop extension amcheck;
+drop extension injection_points;
index a91bd72b9bd4d16249ceba0f9cef13781c5651a5..54c61602d082c611700e82371a2c3b648c6cfd3b 100644 (file)
@@ -39,3 +39,4 @@ SELECT '(1,2)'::t;
  (1,2)
 (1 row)
 
+DROP EXTENSION injection_points;
index c1a3af509c01803722e751d0ea162f81fda5f153..f004a31c32a85e991be24a65d6f6ce8361c7420c 100644 (file)
@@ -19,3 +19,5 @@ SELECT '(1)'::t;
 SELECT injection_points_detach('typecache-before-rel-type-cache-insert');
 ALTER TABLE t ADD COLUMN j int;
 SELECT '(1,2)'::t;
+
+DROP EXTENSION injection_points;