Re: BUG #19686: Rolling back SET TABLESPACE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19686: Rolling back SET TABLESPACE
Date: 2026-09-29 23:39:40
Message-ID: 714053.1790725180@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> I don't think copying the file at commit is a good path, we shouldn't make
> commits take arbitrarily long without pretty darn good reason. I don't think
> this is that.

+1. Moving operations with a significant probability of failure into
COMMIT is also an anti-pattern.

> What about forcing indexes to be copied to a new relfilenode when copying the
> underlying table?

That seems like the logical solution to me. Nobody will be surprised
if ALTER SET TABLESPACE takes a long time for a big table; at least
not if they understand that it requires copying the data somewhere
else. Imposing costs at COMMIT time might well surprise people.

The one disadvantage I see is that (I imagine) a common use-case is
to move both a table and its indexes to a new tablespace, and this
solution will imply that that sequence double-copies the indexes.
Maybe it'd be worth providing a command variant that copies the
table and its indexes to a new tablespace in one step. But that
is a future optimization, not part of the bug fix; and I could be
wrong about whether anyone even cares.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-09-29 23:46:29 Re: injection_points: canceled or terminated waiters leak their wait slots
Previous Message surya poondla 2026-09-29 22:31:31 Re: pg_walinspect: add functions to locate and list WAL by time and LSN