Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4127b7

Browse files
committed
Allow DROP TABLESPACE to succeed (with a warning) if the pg_tblspc symlink
doesn't exist. This allows DROP to be used to clean out the pg_tablespacecatalog entry in a situation where a previous DROP attempt failed beforecommitting but after having removed the directories and symlink.Per report from William Garrison. Even though his test case depends on anunrelated bug in PreventTransactionChain, it's certainly possible for thissituation to arise due to other problems, eg a system crash at just theright time.
1 parent832b6d0 commita4127b7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

‎src/backend/commands/tablespace.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.44 2007/03/13 00:33:40 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.45 2007/03/22 19:51:44 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -523,12 +523,25 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo)
523523
* fresh subdirectories in parallel. It is possible that new files are
524524
* being created within subdirectories, though, so the rmdir call could
525525
* fail. Worst consequence is a less friendly error message.
526+
*
527+
* If redo is true then ENOENT is a likely outcome here, and we allow it
528+
* to pass without comment. In normal operation we still allow it, but
529+
* with a warning. This is because even though ProcessUtility disallows
530+
* DROP TABLESPACE in a transaction block, it's possible that a previous
531+
* DROP failed and rolled back after removing the tablespace directories
532+
* and symlink. We want to allow a new DROP attempt to succeed at
533+
* removing the catalog entries, so we should not give a hard error here.
526534
*/
527535
dirdesc=AllocateDir(location);
528536
if (dirdesc==NULL)
529537
{
530-
if (redo&&errno==ENOENT)
538+
if (errno==ENOENT)
531539
{
540+
if (!redo)
541+
ereport(WARNING,
542+
(errcode_for_file_access(),
543+
errmsg("could not open directory \"%s\": %m",
544+
location)));
532545
pfree(location);
533546
return true;
534547
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp