Re: BUG #19686: Rolling back SET TABLESPACE

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

Hi Shihao,

> v6 keeps the shortcut for both protocols. Its cost is that a
> pipelined ALTER commits on its own, but I think few people send
> SET TABLESPACE in a pipeline with other statements.

It does not take an explicit pipeline. I ran an ALTER TABLE SET
TABLESPACE followed by a failing statement, in autocommit mode,
through the batch API of some common drivers. Where the table ends
up, on master, v6 and v7:

pgJDBC 42.7.13, executeBatch(): pg_default, ts, pg_default
pgx 5.11.0, SendBatch(): pg_default, ts, pg_default
psycopg 3.3.6, pipeline(): pg_default, ts, pg_default

On master each batch is one transaction and the failure rolls the
move back. With v6 the move stays, and the application only sees the
error of the later statement. postgres.js, node-postgres and
tokio-postgres send each statement in its own transaction, so they
see no difference.

> v7 changes no behavior, but the shortcut only helps simple protocol
> clients. For me that means mostly psql.

Agreed, the shortcut is narrower. But v7's cost is time only: the
indexes are copied, which made the ALTER at most about 1.7 times
slower in my tests. And the fix is meant for every branch from
REL_14 on, where a minor release should not change what a failed
batch leaves behind.

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

Agreed. To sum it up for whoever decides: v6 is faster through the
extended protocol and commits the ALTER of a batch on its own; v7
keeps the current behavior and copies the indexes there.

Regards,
Manu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-10-04 20:51:35 Re: postgres_fdw: Fix costing of remote sorts without remote estimates
Previous Message shihao zhong 2026-10-04 19:14:42 Re: BUG #19686: Rolling back SET TABLESPACE