Re: tablespaces inside $PGDATA considered harmful

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tablespaces inside $PGDATA considered harmful
Date: 2015-04-23 02:41:02
Message-ID: 20150423024102.GJ13362@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 30, 2015 at 01:26:22PM -0800, Josh Berkus wrote:
> Robert, Stephen, etc.:
>
> Apparently you can create a tablespace in the tablespace directory:
>
> josh=# create tablespace tbl location '/home/josh/pg94/data/pg_tblspc/';
> CREATE TABLESPACE
> josh=# create table test_tbl ( test text ) tablespace tbl;
> CREATE TABLE
> josh=# \q
> josh(at)Radegast:~/pg94/data/pg_tblspc$ ls
> 17656 PG_9.4_201409291
> josh(at)Radegast:~/pg94/data/pg_tblspc$ ls -l
> total 4
> lrwxrwxrwx 1 josh josh 30 Jan 30 13:02 17656 ->
> /home/josh/pg94/data/pg_tblspc
> drwx------ 3 josh josh 4096 Jan 30 13:02 PG_9.4_201409291
> josh(at)Radegast:~/pg94/data/pg_tblspc$
>
> In theory if I could guess the next OID, I could cause a failure there,
> but that appears to be obscure enough to be not worth bothering about.
>
> What is a real problem is that we don't block creating tablespaces
> anywhere at all, including in obviously problematic places like the
> transaction log directory:
>
> josh=# create tablespace tbl2 location '/home/josh/pg94/data/pg_xlog/';
> CREATE TABLESPACE
>
> It really seems like we ought to block *THAT*. Of course, if we block
> tablespace creation in PGDATA generally, then that's covered.

I have developed the attached patch to warn about creating tablespaces
inside the data directory. The case this doesn't catch is referencing a
symbolic link that points to the same directory. We can't make it an
error so people can use pg_upgrade these setups. This would be for 9.5
only.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
tablespace.diff text/x-diff 755 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2015-04-23 02:45:50 Re: inherit support for foreign tables
Previous Message Jeff Davis 2015-04-23 01:40:33 Re: [BUGS] Failure to coerce unknown type to specific type