public inbox for [email protected]  
help / color / mirror / Atom feed
From: Sami Imseih <[email protected]>
To: Masahiko Sawada <[email protected]>
Cc: Alexander Lakhin <[email protected]>
Cc: pgsql-hackers <[email protected]>
Cc: Daniil Davydov <[email protected]>
Subject: Re: test_autovacuum/001_parallel_autovacuum is broken
Date: Thu, 9 Apr 2026 13:32:33 -0500
Message-ID: <CAA5RZ0uqvjxv5HPzz36UEq-LUf8F+kae61k0imaGw0C0XGa7nw@mail.gmail.com> (raw)
In-Reply-To: <CAD21AoCj=OSxoh3RBw0VWJ7Y7c9EipRhpatcZaHuXKGLWyKgdQ@mail.gmail.com>
References: <CAA5RZ0s+kZZRMSF4HW7tZ9W2jS1o4B+Fg8dr5a-T6mANX+mdQA@mail.gmail.com>
	<[email protected]>
	<CAD21AoCj=OSxoh3RBw0VWJ7Y7c9EipRhpatcZaHuXKGLWyKgdQ@mail.gmail.com>

> The root cause seems to me that it's not guaranteed that we can see
> the autovacuum logs after checking the statistics (i.e.,
> pg_stat_user_tables) as we update the statistics and then write the
> log.
>
> One way to fix the test is to replace log_contains() with
> wait_for_log(). We can also remove wait_for_autovacuum_complete()
> logic altogether.

+1. I was going to reply with exactly this. Attached is the fix.

--
Sami


Attachments:

  [application/octet-stream] v1-0001-Fix-unstable-log_contains-in-parallel-autovacuum-.patch (1.7K, 2-v1-0001-Fix-unstable-log_contains-in-parallel-autovacuum-.patch)
  download | inline diff:
From bb9a9ff4678a3b04d040729fb19e6573aa8edc5b Mon Sep 17 00:00:00 2001
From: Sami Imseih <[email protected]>
Date: Thu, 9 Apr 2026 18:29:05 +0000
Subject: [PATCH v1 1/1] Fix unstable log_contains in parallel autovacuum tests

Replace check_for_log with wait_for_log in the parallel
autovacuum test to force it to wait for the log containing
the parallel vacuum info. Also remove wait_for_autovacuum_complete
as the wait for log is sufficient to determine if the
vacuum completed.
---
 .../test_autovacuum/t/001_parallel_autovacuum.pl   | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

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 fc4dd22f5eb..56ef1af7d08 100644
--- a/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
+++ b/src/test/modules/test_autovacuum/t/001_parallel_autovacuum.pl
@@ -35,17 +35,6 @@ sub prepare_for_next_test
 	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 $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
 
@@ -129,8 +118,7 @@ $node->safe_psql(
 
 # 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.
-wait_for_autovacuum_complete($node, $av_count);
-ok( $node->log_contains(
+ok( $node->wait_for_log(
 		qr/parallel workers: index vacuum: 2 planned, 2 launched in total/,
 		$log_offset));
 
-- 
2.50.1



view thread (20+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: test_autovacuum/001_parallel_autovacuum is broken
  In-Reply-To: <CAA5RZ0uqvjxv5HPzz36UEq-LUf8F+kae61k0imaGw0C0XGa7nw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox