On Tue, Nov 24, 2026 at 10:54 AM Adrian Klaver <[email protected]>
wrote:

> On 11/24/26 6:54 AM, dinesh kumar wrote:
> > Thank you for the clarification, Laurenz.
> >
> > That makes sense regarding the logical content and locking behavior. I
> > appreciate the insight.
> >
> > Agreed on the locks, but I have a slight concern: we changed the
> > completed underlying file (actually rewriting the table),
> > while the transaction mode is READ ONLY.
> >
> > My actual question is: how does a READ ONLY TRANSACTION rewrite the
> > complete table?
>
> https://www.postgresql.org/docs/19/sql-repack.html
>
> "
> Notes on Concurrent Operation
> Warning
>
> REPACK with the CONCURRENTLY option is not MVCC-safe. After the
> repacking transaction commits, the table will appear empty to concurrent
> transactions, if they are using a snapshot taken before repacking
> started. See Section 13.6 for more details.
>

It's still massively counterintuitive to be able to do this.  Even though
REPACK is documented to not be MVCC-safe, the REPACK command should check
to see if it's in a R/O txn, and if so, immediately throw an error.
START TRANSACTION READ ONLY;
REPACK t;                           -- succeeds, AccessExclusiveLock
COMMIT;

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

Reply via email to