Re: [PATCH] VACUUM: avoid pre-creation transactions holding back cleanup of newly created relations

Melanie Plageman <melanieplageman@gmail.com>

From: Melanie Plageman <melanieplageman@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Mikhail Kharitonov <mikhail.kharitonov.dev@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-12-09T19:31:09Z
Lists: pgsql-hackers
On Tue, Dec 9, 2025 at 2:25 PM Andres Freund <andres@anarazel.de> wrote:
>
> Isn't the whole idea that it would be safe to allow freezing in this case
> incorrect?  Consider the following scenario:
>
> A1: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ; SELECT;
> B1: CREATE TABLE foo AS SELECT random();
> B2: VACUUM FREEZE foo;
> A2: SELECT * FROM foo;
>
> If you allowed freezing of the rows in B2, A2 will see the rows as visible,
> despite them not being supposed to be visible.

Is the reason this isn't a problem for COPY FREEZE because the
freezing happens in the same transaction block as creating the table
so A2 wouldn't be able to see the catalog entry for the table?

- Melanie