Re: src/ports/pgcheckdir.c - Ignore dot directories...

From: Sean Chittenden <sean(at)chittenden(dot)org>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, koobs(at)freebsd(dot)org
Subject: Re: src/ports/pgcheckdir.c - Ignore dot directories...
Date: 2013-02-05 14:16:01
Message-ID: 5B7CCB0A-878B-4267-A16E-1426BB8A76A6@chittenden.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> Currently src/port/pgcheckdir.c will reject non-empty
>> directories, which is an issue during initdb(1) when PGDATA is
>> also the mount point for filesystems that support snapshots (e.g.
>> ZFS or UFS2).
>
>> Granted it's not hard to create a subdirectory, initdb there and
>> move the contents of the files around, it's extra work that
>> shouldn't be required.
>
> I feel that it is very bad practice to use the mount point as the
> PGDATA directory. It forcloses a lot of reasonable actions that
> someone managing the database server might want to take.

The only reason I have skin in this game is because pg_check_dir(xlog_dir) is called and I routinely have to work around that nuisance/nugget of joy. Again, just a nuisance.

It's common to create a ZFS dataset for specific applications (`zfs send ... | ssh zfs receive ...`). In SAN environments, mounting a LUN as PGDATA or pg_xlog isn't uncommon either.

I agree it's not ideal for some filesystems, but being overly protective doesn't buy us much either, because in some setups, it's entirely acceptable. If PostgreSQL had the ability to chroot(2) itself, I'd be very opposed to this patch, but as is, it's mostly harmless (the rev that didn't have lost+found, actually).

In thinking about it, I like ignoring the hidden directories and failing when lost+found is present because, IMO, filesystems where lost+found is going to be present are exactly the filesystems that shouldn't have PGDATA located at the top of a mount point.

Personally I'm a fan of having PGDATA's parent directory be its own dataset/filesystem as well, but that's because I want PGDATA's parent directory to include PostgreSQL's minor version number (e.g. zpool datasets: tank/pg tank/pg/data tank/pg/data/9.2), but I digress.

> It's hard to get enthusiastic about a patch to make bad practice
> more convenient. I would rather add a sentence or two to the
> initdb documentation recommending that a cluster not be created at
> a mount point; it should be created in a directory underneath the
> mount point.

Giving filesystem advice is a large topic that I'm sure is covered someplace in the handbook. A general warning isn't a bad idea, however. *shrug*

Regardless, hopefully some of this is of interest to someone.

-sc

--
Sean Chittenden
sean(at)chittenden(dot)org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Albe Laurenz 2013-02-05 14:32:00 Re: src/ports/pgcheckdir.c - Ignore dot directories...
Previous Message Simon Riggs 2013-02-05 14:14:30 Re: src/ports/pgcheckdir.c - Ignore dot directories...