Re: BGWORKER_INTERRUPTIBLE workers are never restarted after DROP/ALTER/CREATE DATABASE

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: BGWORKER_INTERRUPTIBLE workers are never restarted after DROP/ALTER/CREATE DATABASE
Date: 2026-11-09 10:49:41
Message-ID: CABPTF7Vm3YGR=_AvMCtu8GtWxBUu_uK7fd7AGeeBsYEAdGWMkQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 9, 2026 at 4:46 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> > So the attached patch removes the need for a flag, and just relies on
> > a plain kill(). Once we do that, the restart time gets effective when
> > set.
>
> Thanks, this is basically the same thing I had in mind.
>
> I attached a v3 based with a few changes:
>
> * The docs still said "the postmaster sends a termination signal",
> which is no longer true.
> * Added Xuneng's doc comment in the test
> * I also removed the pid <> $pid condition based on Xuneng's comment
> * I changed the max_worker_processes back to total_slots, since that
> seem to be more generally used in these functions
> * There was a typo in the commit message ("restarted or nor")

There seems to be a risk of interpreting the exit of worker & its PID
reuse as non-exit failure here. How about adding a new critera like
process start time for checking that as V4 does.

# Run query and verify that the bgworker with the specified PID has been
# terminated.
sub run_bgworker_interruptible_test
{
my ($node, $command, $testname, $pid) = @_;
my $offset = -s $node->logfile;

...

my $result = $node->safe_psql('postgres',
"SELECT count(*) = 0 FROM pg_stat_activity WHERE pid = $pid;");
is($result, 't', "dynamic bgworker stopped for $testname");
}

--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

Attachment Content-Type Size
v4-0001-Fix-restart-of-interruptible-bgworkers-after-database-commands.patch application/octet-stream 9.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert I Nilsson 2026-11-09 11:09:28 [PATCH] Fix incorrect Unicode code point in saslprep.c comment
Previous Message Fujii Masao 2026-11-09 10:40:45 Re: Add a hint to the "WAL summaries are required" errors