public inbox for [email protected]
help / color / mirror / Atom feedFrom: Michael Paquier <[email protected]>
To: Hayato Kuroda (Fujitsu) <[email protected]>
Cc: 'Tom Lane' <[email protected]>
Cc: Alexander Lakhin <[email protected]>
Cc: Aya Iwata (Fujitsu) <[email protected]>
Cc: Peter Smith <[email protected]>
Cc: Pavel Stehule <[email protected]>
Cc: Chao Li <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
Date: Sun, 5 Apr 2026 20:47:30 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <OS9PR01MB12149DEAB9D2FAF32C1E8079DF551A@OS9PR01MB12149.jpnprd01.prod.outlook.com>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<OS9PR01MB12149DEAB9D2FAF32C1E8079DF551A@OS9PR01MB12149.jpnprd01.prod.outlook.com>
On Thu, Apr 02, 2026 at 03:20:59AM +0000, Hayato Kuroda (Fujitsu) wrote:
> Thanks for paying attention the thread.
> I've been considering why the XLogFileClose() is slow only on widowbird but I
> have no idea. But on this thread, I think we can just put a workaround for
> stabilization.
I am not convinced that we have a need for an environment variable for
this case, TBH. It would be enough to make sure that the spawned
worker is paused on its WaitLatch(), with a naptime large enough to
allow the initial transaction to commit, as in the attached. When the
interruption is run, the worker would stop at CHECK_FOR_INTERRUPTS(),
before beginning a new transaction.
--
Michael
From fe0a2284d87930cd18d13ff4c473f96de5a965e8 Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
Date: Sun, 5 Apr 2026 20:45:16 +0900
Subject: [PATCH] Improve stability of worker_spi termination test
This switches the test to wait for the spawned bgworkers to reach their
main loops, napping. worker_spi.naptime is enlarged to 10 minutes to
give enough room for slow machines to reach this state.
---
.../worker_spi/t/002_worker_terminate.pl | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/test/modules/worker_spi/t/002_worker_terminate.pl b/src/test/modules/worker_spi/t/002_worker_terminate.pl
index b0e6a5376d4c..a7d507cc0596 100644
--- a/src/test/modules/worker_spi/t/002_worker_terminate.pl
+++ b/src/test/modules/worker_spi/t/002_worker_terminate.pl
@@ -20,7 +20,6 @@ if ($ENV{enable_injection_points} ne 'yes')
sub launch_bgworker
{
my ($node, $database, $testcase, $interruptible) = @_;
- my $offset = -s $node->logfile;
# Launch a background worker on the given database.
my $pid = $node->safe_psql(
@@ -28,13 +27,11 @@ sub launch_bgworker
SELECT worker_spi_launch($testcase, '$database'::regdatabase, 0, '{}', $interruptible);
));
- # Check that the bgworker is initialized.
- $node->wait_for_log(
- qr/LOG: .*worker_spi dynamic worker $testcase initialized with .*\..*/,
- $offset);
- my $result = $node->safe_psql('postgres',
- "SELECT count(*) > 0 FROM pg_stat_activity WHERE pid = $pid;");
- is($result, 't', "dynamic bgworker $testcase launched");
+ # Check that the bgworker is initialized and napping.
+ my $result = $node->poll_query_until('postgres',
+ qq[SELECT wait_event FROM pg_stat_activity WHERE pid = $pid;],
+ qq[WorkerSpiMain]);
+ is($result, 1, "dynamic bgworker $testcase launched");
return $pid;
}
@@ -64,11 +61,15 @@ sub run_bgworker_interruptible_test
my $node = PostgreSQL::Test::Cluster->new('mynode');
$node->init;
+# The naptime is large enough to give room on slow machines to reach
+# the main loop of the spawned workers, after these initialize their
+# schemas.
$node->append_conf(
"postgresql.conf", qq(
autovacuum = off
debug_parallel_query = off
log_min_messages = debug1
+worker_spi.naptime = 600
));
$node->start;
--
2.53.0
Attachments:
[text/plain] 0001-Improve-stability-of-worker_spi-termination-test.patch (2.2K, 2-0001-Improve-stability-of-worker_spi-termination-test.patch)
download | inline diff:
From fe0a2284d87930cd18d13ff4c473f96de5a965e8 Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
Date: Sun, 5 Apr 2026 20:45:16 +0900
Subject: [PATCH] Improve stability of worker_spi termination test
This switches the test to wait for the spawned bgworkers to reach their
main loops, napping. worker_spi.naptime is enlarged to 10 minutes to
give enough room for slow machines to reach this state.
---
.../worker_spi/t/002_worker_terminate.pl | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/test/modules/worker_spi/t/002_worker_terminate.pl b/src/test/modules/worker_spi/t/002_worker_terminate.pl
index b0e6a5376d4c..a7d507cc0596 100644
--- a/src/test/modules/worker_spi/t/002_worker_terminate.pl
+++ b/src/test/modules/worker_spi/t/002_worker_terminate.pl
@@ -20,7 +20,6 @@ if ($ENV{enable_injection_points} ne 'yes')
sub launch_bgworker
{
my ($node, $database, $testcase, $interruptible) = @_;
- my $offset = -s $node->logfile;
# Launch a background worker on the given database.
my $pid = $node->safe_psql(
@@ -28,13 +27,11 @@ sub launch_bgworker
SELECT worker_spi_launch($testcase, '$database'::regdatabase, 0, '{}', $interruptible);
));
- # Check that the bgworker is initialized.
- $node->wait_for_log(
- qr/LOG: .*worker_spi dynamic worker $testcase initialized with .*\..*/,
- $offset);
- my $result = $node->safe_psql('postgres',
- "SELECT count(*) > 0 FROM pg_stat_activity WHERE pid = $pid;");
- is($result, 't', "dynamic bgworker $testcase launched");
+ # Check that the bgworker is initialized and napping.
+ my $result = $node->poll_query_until('postgres',
+ qq[SELECT wait_event FROM pg_stat_activity WHERE pid = $pid;],
+ qq[WorkerSpiMain]);
+ is($result, 1, "dynamic bgworker $testcase launched");
return $pid;
}
@@ -64,11 +61,15 @@ sub run_bgworker_interruptible_test
my $node = PostgreSQL::Test::Cluster->new('mynode');
$node->init;
+# The naptime is large enough to give room on slow machines to reach
+# the main loop of the spawned workers, after these initialize their
+# schemas.
$node->append_conf(
"postgresql.conf", qq(
autovacuum = off
debug_parallel_query = off
log_min_messages = debug1
+worker_spi.naptime = 600
));
$node->start;
--
2.53.0
[application/pgp-signature] signature.asc (833B, 3-signature.asc)
download
view thread (67+ messages)
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], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
In-Reply-To: <[email protected]>
* 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