Re: BUG #16577: Segfault on altering a table located in a dropped tablespace

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16577: Segfault on altering a table located in a dropped tablespace
Date: 2020-08-09 13:20:54
Message-ID: 20200809132054.GE17986@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, Aug 09, 2020 at 11:00:01AM +0000, PG Bug reporting form wrote:
> When executing the following query (a modified excerpt from the tablespace
> regression test):
> CREATE TABLESPACE regress_tblspace LOCATION '@testtablespace@';
> CREATE TABLE test_default_tab_p(id bigint, val bigint)
> PARTITION BY LIST (id) TABLESPACE regress_tblspace;
> CREATE INDEX test_index2 on test_default_tab_p (val) TABLESPACE
> regress_tblspace;
> DROP TABLESPACE regress_tblspace;
> \d+ test_default_tab_p;
> ALTER TABLE test_default_tab_p ALTER val TYPE bigint;

Thanks Alexander for the report. Interesting case indeed.
For a normal table we would complain that the tablespace is not empty
when attempting to drop the tablespace. But here we have only one
partitioned table still holding references to the tablespace. Things
get even more spicy with stuff like that, once you try to play with
the orphaned tablespace reference:
CREATE TABLESPACE popo location '/tmp/popo';
CREATE TABLE parent_tab (a int) partition by list (a) tablespace popo;
DROP TABLESPACE popo;
CREATE TABLE child_tab partition of parent_tab for values in (1);
ERROR: 58P01: could not create directory
"pg_tblspc/24587/PG_12_201909212/16384": No such file or directory
LOCATION: TablespaceCreateDbspace, tablespace.c:161

The issue with indexes is present since 11, but we have more as
reltablespace gets also set for partitioned tables since 12.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-08-09 16:53:05 Re: BUG #16577: Segfault on altering a table located in a dropped tablespace
Previous Message PG Bug reporting form 2020-08-09 11:00:01 BUG #16577: Segfault on altering a table located in a dropped tablespace