Re: Parallel autovacuum: DROP DATABASE WITH (FORCE) fails on the parallel workers

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel autovacuum: DROP DATABASE WITH (FORCE) fails on the parallel workers
Date: 2026-10-14 04:00:00
Message-ID: CALj2ACW-hUKx1Ay5Kq7pxjTr2be1w3_XdUB2sCKgQ2tTHbCmgA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Oct 13, 2026 at 4:17 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> > > Fine with me. But probably can we remove leader->databaseId ==
> > > databaseId check? It seems redundant for parallel workers.
>
> > That's correct, but I would like to be more cautious here, so I
> > retained it. I also added a check that the parallel worker's
> > advertised role is the bootstrap superuser, again to be more cautious.
>
> Hmm, I don't think these checks narrow the case. When the leader
> advertises no role, it goes through
> InitializeSessionUserIdStandalone(), so its parallel workers always
> run as the bootstrap superuser and connect to the same database. So
> both checks are always true once !OidIsValid(leader->roleId) holds.
> Even if a worker advertised another role, I think judging it by its
> leader would still be fine, since we accept terminating the leader and
> the worker exits with it anyway. So I'd prefer to remove both checks,
> as they make readers think when they could be false.

Agreed, let me not be over-cautious. We likely don't, and never will,
change InitializeSessionUserIdStandalone() for such bg/parallel
workers. I will remove both the database OID and bootstrap superuser
checks in the next version.

> Also, regarding the following documentation change:
>
> - This terminates background worker connections and connections that the
> - current user has permission to terminate
> + This terminates background worker connections, the parallel workers they
> + launch, and connections that the current user has permission to terminate
>
> I think we don't need this change as parallel workers are background
> workers, no?

I would like to keep it for clarity, especially since not every
parallel worker is exempted here, only the ones started by autovacuum
workers or bg workers.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-14 04:02:30 Re: [PG19] jsonb_object_agg as a window function returns stale values
Previous Message Manu 2026-10-14 03:59:52 Re: generic plans and "initial" pruning