From: Melanie Plageman Date: Tue, 21 Apr 2026 18:36:59 +0000 (-0400) Subject: Stabilize plancache test against on-access VM setting X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85ae8ab05334f335e3b97d4a4b6309f926eda39c;p=thirdparty%2Fpostgresql.git Stabilize plancache test against on-access VM setting Since b46e1e54d07 allowed setting the VM on-access and 378a21618 set pd_prune_xid on INSERT, the testing of generic/custom plans in src/test/regress/sql/plancache.sql was destabilized. One of the queries of test_mode could have set the pages all-visible and if autovacuum/autoanalyze ran and updated pg_class.relallvisible, it would affect whether we got an index-only or sequential scan. Preclude this by disabling autovacuum and autoanalyze for test_mode and carefully sequencing when ANALYZE is run. Reported-by: Alexander Lakhin Author: Melanie Plageman Discussion: https://postgr.es/m/71277259-264e-4983-a201-938b404049d7%40gmail.com --- diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out index 4e59188196c..d58534ca1cd 100644 --- a/src/test/regress/expected/plancache.out +++ b/src/test/regress/expected/plancache.out @@ -279,10 +279,14 @@ execute pstmt_def_insert(1); drop table pc_list_parted, pc_list_part_null; deallocate pstmt_def_insert; -- Test plan_cache_mode -create table test_mode (a int); +create table test_mode (a int) with (autovacuum_enabled = false); insert into test_mode select 1 from generate_series(1,1000) union all select 2; -create index on test_mode (a); +-- ANALYZE before creating the index. CREATE INDEX scans the table, which may +-- set pages all-visible via on-access pruning. If relallvisible is then updated +-- by ANALYZE, the generic plan may pick an index-only scan instead of the +-- expected sequential scan. analyze test_mode; +create index on test_mode (a); prepare test_mode_pp (int) as select count(*) from test_mode where a = $1; select name, generic_plans, custom_plans from pg_prepared_statements where name = 'test_mode_pp'; diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql index 4b2f11dcc64..aed388d03a1 100644 --- a/src/test/regress/sql/plancache.sql +++ b/src/test/regress/sql/plancache.sql @@ -180,10 +180,15 @@ deallocate pstmt_def_insert; -- Test plan_cache_mode -create table test_mode (a int); +create table test_mode (a int) with (autovacuum_enabled = false); insert into test_mode select 1 from generate_series(1,1000) union all select 2; -create index on test_mode (a); + +-- ANALYZE before creating the index. CREATE INDEX scans the table, which may +-- set pages all-visible via on-access pruning. If relallvisible is then updated +-- by ANALYZE, the generic plan may pick an index-only scan instead of the +-- expected sequential scan. analyze test_mode; +create index on test_mode (a); prepare test_mode_pp (int) as select count(*) from test_mode where a = $1; select name, generic_plans, custom_plans from pg_prepared_statements