Re: BUG #19686: Rolling back SET TABLESPACE

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19686: Rolling back SET TABLESPACE
Date: 2026-10-14 06:04:54
Message-ID: 179195789433.990372.6387431139267045114@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Shihao,

> I personally prefer v6, but that should be a committer decision.

Agreed it's a committer call. I'm re-attaching v7 as a plain .patch: it
went as .patch.txt before, which the cfbot skips, so the entry was still
testing the first version. No code change -- it applies unchanged on
today's master and REL_19 through REL_14, make check and the standby,
crash and wal_level=minimal checks are green on each, and the regression
test fails without the fix.

For whoever makes the v6-vs-v7 call, the two differ only in the shortcut
that skips copying the indexes:

- v6 keeps the shortcut for both protocols. Its cost is that a
SET TABLESPACE that is the first statement of a pipeline commits on
its own, so a later failure in that pipeline no longer rolls the
move back.

- v7 drops that. The shortcut then applies only to a single-statement
simple-protocol query, so through the extended protocol (most
drivers) the ALTER always copies the indexes: more WAL and one lock
per index, and it can fail if the destination tablespace has room
for the heap but not for the indexes.

I attached v7, as the one that changes no behavior, but either is ready
and I'm happy to switch to v6 if that's the preference.

One user-visible change in both: when the indexes are copied, the
destination tablespace has to have room for them too, not just the heap.

Regards,
Manu

Attachment Content-Type Size
v7-0001-Fix-index-corruption-after-rolling-back-ALTER-TAB.patch text/x-patch 26.8 KB
v7-REL_17-0001-Fix-index-corruption-after-rolling-back-ALTER-TAB.patch.txt text/plain 26.8 KB
v7-REL_16-0001-Fix-index-corruption-after-rolling-back-ALTER-TAB.patch.txt text/plain 26.8 KB
v7-REL_15-0001-Fix-index-corruption-after-rolling-back-ALTER-TAB.patch.txt text/plain 25.8 KB
v7-REL_14-0001-Fix-index-corruption-after-rolling-back-ALTER-TAB.patch.txt text/plain 25.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-10-14 06:06:52 Re: ERROR: SubPlan found with no parent plan
Previous Message Richard Guo 2026-10-14 06:02:29 Re: "failed to build any N-way joins" from a five-relation query