Re: Adding REPACK [concurrently] - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Adding REPACK [concurrently]
Date
Msg-id zefg3dww5q5iayo46mdiqgsewtwx3qv3jp2utzj5ucxdc7isvu@3q7szybdkmdx
Whole thread
In response to Re: Adding REPACK [concurrently]  (Mihail Nikalayeu <mihailnikalayeu@gmail.com>)
List pgsql-hackers
Hi,

On 2026-04-09 01:36:00 +0200, Mihail Nikalayeu wrote:
> Hello, Andres!
> 
> On Wed, Apr 8, 2026 at 7:22 PM Andres Freund <andres@anarazel.de> wrote:
> > I don't think this is a viable path.  You need to prevent any further lock
> > acquisitions on the relation to be able to swap it, not just conflicting DDL.
> 
> AFAIU, Amit's main idea is that we currently upgrade the lock instead
> of **releasing and re-acquiring** it because we fear DDL between those
> actions.

I got that, I just don't think it's going to work in any sort of way
reasonably well.

The fix here should be to make the system understand how to make lock upgrades
as safe as possible, not to hack around the corners.  For that you need to
teach the deadlock detector about all of this properly.


> > I don't think CheckTableNotInUse() would work anyway - don't we already hold
> > locks by the point we call it?
> 
> Yes, the DDL session already holds locks by the time
> CheckTableNotInUse is called - but is that really the problem? They
> will be released on error.

There's no guarantee they get there if it's done after the lock
acquisition. It can be part of a more complicated lock cycle.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Mihail Nikalayeu
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Andres Freund
Date:
Subject: Re: Adding REPACK [concurrently]