Re: BUG #19686: Rolling back SET TABLESPACE - Mailing list pgsql-hackers

From Andres Freund
Subject Re: BUG #19686: Rolling back SET TABLESPACE
Date
Msg-id ylvsxvklxnjwdnbzgn3cnvcq7poxy3i7nal2sbcynq2yokqhmw@qf6muptzdoia
Whole thread
In response to Re: BUG #19686: Rolling back SET TABLESPACE  (Manu <manuelreyesbravo@gmail.com>)
Responses Re: BUG #19686: Rolling back SET TABLESPACE
List pgsql-hackers
Hi,

On 2026-10-02 14:18:00 -0300, Manu wrote:
> The indexes only need to share the heap's rewrite when the table is
> modified again in the same transaction, which is also the only time the
> corruption can arise.  So leave SET TABLESPACE itself alone, and give an
> index a new relfilenumber -- copying it within its own tablespace, as
> documented, the indexes stay where they are -- when the executor opens
> it to modify a table whose storage was replaced in the current
> transaction

I'm pretty doubtful that is a good idea. For one it'll make the performance
effects very hard to understand.  Having a single insert suddenly taking an
hour will confuse folks rather profoundly.

I also suspect there might be some correctness issues, because you could have
nested queries where the outer query has an in-progress index scan or such and
then a query within e.g. a plpgsql function does an insert. The outer query
might have some buffers of the "old" index pinned etc, which certainly would
not make it safe to just move the relfilenode underneath.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Use instr_time for pg_stat_database block read/write time counters
Next
From: Tom Lane
Date:
Subject: Re: BUG #19686: Rolling back SET TABLESPACE