Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, Steve Singer <steve(at)ssinger(dot)info>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Jose Luis Tallon <jltallon(at)adv-solutions(dot)net>
Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Date: 2021-02-15 02:58:02
Message-ID: YCnjOoYzeSDMFJT2@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Feb 14, 2021 at 08:10:50PM -0600, Justin Pryzby wrote:
> Isn't this dead code ?

Nope, it's not dead. Those two code paths can be hit when attempting
a reidex with a tablespace move directly on toast tables and indexes,
see:
=# create table aa (a text);
CREATE TABLE
=# select relname from pg_class where oid > 16000;
relname
----------------------
aa
pg_toast_16385
pg_toast_16385_index
(3 rows)
=# reindex (concurrently, tablespace pg_default) table
pg_toast.pg_toast_16385;
ERROR: 0A000: cannot move system relation "pg_toast_16385"
LOCATION: ReindexRelationConcurrently, indexcmds.c:3295
=# reindex (concurrently, tablespace pg_default) index
pg_toast.pg_toast_16385_index;
ERROR: 0A000: cannot move system relation "pg_toast_16385_index"
LOCATION: ReindexRelationConcurrently, indexcmds.c:3439

It is easy to save the relation name using \gset in a regression test,
but we had better keep a reference to the relation name in the error
message so this would not be really portable. Using a PL function to
do that with a CATCH block would not work either as CONCURRENTLY
cannot be run in a transaction block. This leaves 090_reindexdb.pl,
but I was not really convinced that this was worth the extra test
cycles (I am aware of the --tablespace option missing in reindexdb,
someone I know was trying to get that done for the next CF).
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiro Ikeda 2021-02-15 02:59:48 Re: About to add WAL write/fsync statistics to pg_stat_wal view
Previous Message Bharath Rupireddy 2021-02-15 02:43:49 Re: Support ALTER SUBSCRIPTION ... ADD/DROP PUBLICATION ... syntax