pgsql: Fix DROP TABLESPACE to unlink symlink when directory is not ther - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix DROP TABLESPACE to unlink symlink when directory is not ther
Date
Msg-id E1STgwj-000573-JX@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix DROP TABLESPACE to unlink symlink when directory is not there.

If the tablespace directory is missing entirely, we allow DROP TABLESPACE
to go through, on the grounds that it should be possible to clean up the
catalog entry in such a situation.  However, we forgot that the pg_tblspc
symlink might still be there.  We should try to remove the symlink too
(but not fail if it's no longer there), since not doing so can lead to
weird behavior subsequently, as per report from Michael Nolan.

There was some discussion of adding dependency links to prevent DROP
TABLESPACE when the catalogs still contain references to the tablespace.
That might be worth doing too, but it's an orthogonal question, and in
any case wouldn't be back-patchable.

Back-patch to 9.0, which is as far back as the logic looks like this.
We could possibly do something similar in 8.x, but given the lack of
reports I'm not sure it's worth the trouble, and anyway the case could
not arise in the form the logic is meant to cover (namely, a post-DROP
transaction rollback having resurrected the pg_tablespace entry after
some or all of the filesystem infrastructure is gone).

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b8347138e94c4e712334508c460cbe0062d21e70

Modified Files
--------------
src/backend/commands/tablespace.c |   15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Re-revert stats collector latch changes.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix DROP TABLESPACE to unlink symlink when directory is not ther