Re: REPACK (CONCURRENTLY) fails when table owner lacks CONNECT

From: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Cc: alvherre(at)kurilemu(dot)de
Subject: Re: REPACK (CONCURRENTLY) fails when table owner lacks CONNECT
Date: 2026-08-27 18:16:31
Message-ID: 3afc9eed-67eb-45a6-8e15-5972404635c3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27/08/26 12:46, Nathan Bossart wrote:
> The REPACK decoding worker doesn't pass BGWORKER_BYPASS_ALLOWCONN like
> parallel.c does, so it can fail to start. Here is a reproducer:
>
> CREATE DATABASE d;
> REVOKE CONNECT ON DATABASE d FROM PUBLIC;
> \c d
> CREATE ROLE r NOLOGIN;
> CREATE TABLE t (a INT PRIMARY KEY);
> ALTER TABLE t OWNER TO r;
> REPACK t; -- works
> REPACK (CONCURRENTLY) t; -- fails
>
> That last command produces the following output:
>
> ERROR: permission denied for database "d"
> DETAIL: User does not have CONNECT privilege.
> CONTEXT: REPACK decoding worker
>
> This one seems easy enough to fix.
>

I'm attaching a patch to use BGWORKER_BYPASS_ALLOWCONN on
BackgroundWorkerInitializeConnectionByOid as parallel.c.

I also added a test case for it.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
0001-Let-the-REPACK-decoding-worker-bypass-connection-pri.patch text/plain 4.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Diego 2026-08-27 18:18:28 Re: [Proposal] add portaddr like hostaddr
Previous Message Zsolt Parragi 2026-08-27 18:14:37 Re: scary patch contest