From aa7bf69a232c5adbb2dca791cd76ea7e92b15cd8 Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Tue, 18 Mar 2025 23:11:14 +0500 Subject: [PATCH v9 2/4] Review fixes --- src/backend/access/nbtree/nbtree.c | 13 ++++++++----- src/test/modules/test_misc/t/008_vacuum_btree.pl | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index fe7084edacd..02688d90fe7 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -1089,7 +1089,7 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, if (p.current_blocknum >= num_pages) break; - /* In 007_vacuum_btree test we need to coordinate two distinguishable points here */ + /* In 008_vacuum_btree test we need to coordinate two distinguishable points here */ INJECTION_POINT("nbtree-vacuum-1"); INJECTION_POINT("nbtree-vacuum-2"); @@ -1135,7 +1135,7 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, * btvacuumpage --- VACUUM one page * * This processes a single page for btvacuumscan(). In some cases we must - * backtrack to re-examine and VACUUM pages that were the scanblkno during + * backtrack to re-examine and VACUUM pages that were on buf's page during * a previous call here. This is how we handle page splits (that happened * after our cycleid was acquired) whose right half page happened to reuse * a block that we might have processed at some point before it was @@ -1166,9 +1166,6 @@ backtrack: attempt_pagedel = false; backtrack_to = P_NONE; - /* call vacuum_delay_point while not holding any buffer lock */ - vacuum_delay_point(false); - _bt_lockbuf(rel, buf, BT_READ); page = BufferGetPage(buf); opaque = NULL; @@ -1456,6 +1453,9 @@ backtrack: { blkno = backtrack_to; + /* call vacuum_delay_point while not holding any buffer lock */ + vacuum_delay_point(false); + /* * We can't use _bt_getbuf() here because it always applies * _bt_checkpage(), which will barf on an all-zero page. We want to @@ -1466,6 +1466,9 @@ backtrack: info->strategy); goto backtrack; } + + /* call vacuum_delay_point while not holding any buffer lock */ + vacuum_delay_point(false); return scanblkno; } diff --git a/src/test/modules/test_misc/t/008_vacuum_btree.pl b/src/test/modules/test_misc/t/008_vacuum_btree.pl index 2c69d2b477d..8ec56c419a3 100644 --- a/src/test/modules/test_misc/t/008_vacuum_btree.pl +++ b/src/test/modules/test_misc/t/008_vacuum_btree.pl @@ -16,8 +16,6 @@ if ($ENV{enable_injection_points} ne 'yes') } # Initialize postgres -my $psql_err = ''; -my $psql_out = ''; my $node = PostgreSQL::Test::Cluster->new('node'); $node->init; @@ -47,7 +45,7 @@ $psql_session->query_until( create table a as select random() r from generate_series(1,100) x; create index on a(r); delete from a; - vacuum (index_cleanup on) a; + vacuum (index_cleanup on, parallel 0) a; )); # Wait until an vacuum worker starts. -- 2.39.5 (Apple Git-154)