v28-0006-fixup-updates-tap-tests.patch
application/x-patch
Filename: v28-0006-fixup-updates-tap-tests.patch
Type: application/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v28-0006
Subject: fixup: updates tap tests.
| File | + | − |
|---|---|---|
| src/backend/commands/vacuumparallel.c | 1 | 8 |
| src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl | 32 | 25 |
From 90769faf15b6d830cafb42380b9ec5f5ff974913 Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Mon, 16 Mar 2026 18:01:45 -0700
Subject: [PATCH v28 6/7] fixup: updates tap tests.
---
src/backend/commands/vacuumparallel.c | 9 +--
.../t/001_parallel_autovacuum.pl | 57 +++++++++++--------
2 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index ef36b9bd286..62b6f50b538 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -656,7 +656,7 @@ parallel_vacuum_update_shared_delay_params(void)
shared_params_generation_local = params_generation;
elog(DEBUG2,
- "parallel autovacuum worker cost params: cost_limit=%d, cost_delay=%g, cost_page_miss=%d, cost_page_dirty=%d, cost_page_hit=%d",
+ "parallel autovacuum worker updated cost params: cost_limit=%d, cost_delay=%g, cost_page_miss=%d, cost_page_dirty=%d, cost_page_hit=%d",
vacuum_cost_limit,
vacuum_cost_delay,
VacuumCostPageMiss,
@@ -933,13 +933,6 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
for (int i = 0; i < pvs->pcxt->nworkers_launched; i++)
InstrAccumParallelQuery(&pvs->buffer_usage[i], &pvs->wal_usage[i]);
-
- if (AmAutoVacuumWorkerProcess())
- elog(DEBUG2,
- ngettext("autovacuum worker: finished parallel index processing with %d parallel worker",
- "autovacuum worker: finished parallel index processing with %d parallel workers",
- nworkers),
- nworkers);
}
/*
diff --git a/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl b/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
index 9ad87d48b96..0147ee33c93 100644
--- a/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
+++ b/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
@@ -11,8 +11,8 @@ if ($ENV{enable_injection_points} ne 'yes')
}
# Before each test we should disable autovacuum for 'test_autovac' table and
-# generate some dead tuples in it.
-
+# generate some dead tuples in it. Returns the current autovacuum_count of
+# the table tset_autovac.
sub prepare_for_next_test
{
my ($node, $test_number) = @_;
@@ -21,12 +21,25 @@ sub prepare_for_next_test
ALTER TABLE test_autovac SET (autovacuum_enabled = false);
UPDATE test_autovac SET col_1 = $test_number;
});
+
+ my $count = $node->safe_psql('postgres',
+ qq{SELECT autovacuum_count FROM pg_stat_user_tables WHERE relname = 'test_autovac'});
+
+ return $count;
}
+# Wait for the table to be vacuumed by an autovacuum worker.
+sub wait_for_autovacuum_complete
+{
+ my ($node, $old_count) = @_;
+
+ $node->poll_query_until('postgres',
+ qq{SELECT autovacuum_count > $old_count FROM pg_stat_user_tables WHERE relname = 'test_autovac'});
+}
my $psql_out;
-my $node = PostgreSQL::Test::Cluster->new('node1');
+my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
# Configure postgres, so it can launch parallel autovacuum workers, log all
@@ -54,7 +67,7 @@ $node->safe_psql('postgres', qq{
CREATE EXTENSION injection_points;
});
-my $indexes_num = 4;
+my $indexes_num = 3;
my $initial_rows_num = 10_000;
my $autovacuum_parallel_workers = 2;
@@ -91,7 +104,8 @@ $node->safe_psql('postgres', qq{
# Our table has enough indexes and appropriate reloptions, so autovacuum must
# be able to process it in parallel mode. Just check if it can do it.
-prepare_for_next_test($node, 1);
+my $av_count = prepare_for_next_test($node, 1);
+my $log_offset = -s $node->logfile;
$node->safe_psql('postgres', qq{
ALTER TABLE test_autovac SET (autovacuum_enabled = true);
@@ -99,16 +113,16 @@ $node->safe_psql('postgres', qq{
# Wait until the parallel autovacuum on table is completed. At the same time,
# we check that the required number of parallel workers has been started.
-$log_start = $node->wait_for_log(
- qr/autovacuum worker: finished parallel index processing with 2 parallel workers/,
- $log_start
-);
+wait_for_autovacuum_complete($node, $av_count);
+ok( $node->log_contains(qr/parallel workers: index vacuum: 2 planned, 2 launched in total/,
+ $log_offset));
# Test 2:
# Check whether parallel autovacuum leader can propagate cost-based parameters
# to the parallel workers.
-prepare_for_next_test($node, 2);
+$av_count = prepare_for_next_test($node, 2);
+$log_offset = -s $node->logfile;
$node->safe_psql('postgres', qq{
SELECT injection_points_attach('autovacuum-start-parallel-vacuum', 'wait');
@@ -123,8 +137,7 @@ $node->wait_for_event(
'autovacuum-start-parallel-vacuum'
);
-# Reload config - leader worker must update its own parameters during indexes
-# processing
+# Update the shared cost-based delay parameters.
$node->safe_psql('postgres', qq{
ALTER SYSTEM SET vacuum_cost_limit = 500;
ALTER SYSTEM SET vacuum_cost_page_miss = 10;
@@ -133,12 +146,12 @@ $node->safe_psql('postgres', qq{
SELECT pg_reload_conf();
});
+# Resume the leader process to update the shared parameters during heap scan (i.e.
+# vacuum_delay_point() is called) and launch a parallel vacuum worker, but it stops
+# before vacuuming indexes due to the injection point.
$node->safe_psql('postgres', qq{
SELECT injection_points_wakeup('autovacuum-start-parallel-vacuum');
});
-
-# Now wait until parallel autovacuum leader completes processing table (i.e.
-# guaranteed to call vacuum_delay_point) and launches parallel worker.
$node->wait_for_event(
'autovacuum worker',
'autovacuum-leader-before-indexes-processing'
@@ -146,24 +159,18 @@ $node->wait_for_event(
# Check whether parallel worker successfully updated all parameters during
# index processing
-$log_start = $node->wait_for_log(
- qr/parallel autovacuum worker cost params: cost_limit=500, cost_delay=2, / .
- qr/cost_page_miss=10, cost_page_dirty=10, cost_page_hit=10/,
- $log_start
-);
+$node->wait_for_log(qr/parallel autovacuum worker updated cost params: cost_limit=500, cost_delay=2, cost_page_miss=10, cost_page_dirty=10, cost_page_hit=10/,
+ $log_offset);
# Cleanup
$node->safe_psql('postgres', qq{
- SELECT injection_points_wakeup('autovacuum-leader-before-indexes-processing');
-
SELECT injection_points_detach('autovacuum-start-parallel-vacuum');
SELECT injection_points_detach('autovacuum-leader-before-indexes-processing');
- ALTER TABLE test_autovac SET (autovacuum_parallel_workers = $autovacuum_parallel_workers);
+ SELECT injection_points_wakeup('autovacuum-leader-before-indexes-processing');
});
-# We were able to get to this point, so everything is fine.
-ok(1);
+wait_for_autovacuum_complete($node, $av_count);
$node->stop;
done_testing();
--
2.53.0