Re: REPACK (CONCURRENTLY) doesn't check the table AM

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, alvherre(at)kurilemu(dot)de
Subject: Re: REPACK (CONCURRENTLY) doesn't check the table AM
Date: 2026-09-04 21:04:29
Message-ID: CAD21AoBqLtyw7CG82ci69=NC6wBrF0roouJRsV2ii5TGhSY3+g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 31, 2026 at 8:46 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> Hi,
>
> On Thu, Aug 27, 2026 at 3:51 PM Bharath Rupireddy
> <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> >
> > > On Thu, Aug 27, 2026 at 12:57 PM Bharath Rupireddy
> > > <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> > > >
> > > > > If the table AM doesn't support logical decoding, concurrent repack
> > > > > would silently lose some table data as it misses the changes
> > > > > happened during the rewrites.
> > > >
> > > > Yes, that's correct. I came to the same conclusion.
>
> Please find the attached v3 patch with a test added similar to other
> restricted error cases. Sorry for the noise.

I've looked at the patch and have one comment:

+ if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)

Probably it's better to use GetHeapamTableAmRoutine() instead of using
heap AM oid. It would allow the following use case the patch adds in
the regression tests:

+CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;
+CREATE TABLE repack_conc_heap2 (i int) USING heap2;
+REPACK (CONCURRENTLY) repack_conc_heap2;

REPACK'ing on such a table technically works fine. It's unlikely to
drop the check so I think we can add the check without regression
tests.

I attached the updated patch. Please review it.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v4-0001-Restrict-REPACK-CONCURRENTLY-to-the-heap-access-m.patch text/x-patch 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-09-04 21:15:00 Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Previous Message Paul A Jungwirth 2026-09-04 21:03:30 Document the privileges FOR PORTION OF needs on the range column