Adrian Klaver <[email protected]> writes:
> On 11/24/26 8:04 AM, dinesh kumar wrote:
>> Given all these write operations on disk, shouldn't this activity be 
>> restricted inside a READ ONLY transaction?

> https://www.postgresql.org/docs/19/sql-set-transaction.html
> "The transaction access mode determines whether the transaction is 
> read/write or read-only. Read/write is the default.  [...] This is a 
> high-level notion of read-only that does not prevent all writes to disk."

I agree that the fact that REPACK performs writes doesn't disqualify
it from being done inside a READ ONLY transaction.  To my mind the
essential characteristic we expect of READ ONLY is that it doesn't
change the logical state of the database from the viewpoint of other
transactions.  But the thing that gives me pause is

>>> REPACK with the CONCURRENTLY option is not MVCC-safe.

It is very hard to claim that an operation that behaves like that
doesn't change the state of the database in a visible way.
So I tend to agree that REPACK ought to be rejected when
default_transaction_read_only=1.  You could maybe say that we
only reject it with CONCURRENTLY, but that feels a little weird;
I'd just do it always.

                        regards, tom lane


Reply via email to