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

Commiteeb3c2d

Browse files
committed
Back off chattiness in RemovePgTempFiles().
In commit561885d, as part of normalizing RemovePgTempFiles's errorhandling, I removed its behavior of silently ignoring ENOENT failuresduring directory opens. Thomas Munro points out that this is a bad idea atthe top level, because we don't create pgsql_tmp directories until needed.Thus this coding could produce LOG messages in perfectly normal situations,which isn't what I intended. Restore the suppression of ENOENT logging,but only at top level --- it would still be unexpected for a nested tempdirectory to disappear between seeing it in the parent directory andopening it.Discussion:https://postgr.es/m/CAEepm=2y06SehAkTnd5sU_eVqdv5P-=Srt1y5vYNQk6yVDVaPw@mail.gmail.com
1 parent6271fce commiteeb3c2d

File tree

1 file changed

+20
-8
lines changed
  • src/backend/storage/file

1 file changed

+20
-8
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ static intFreeDesc(AllocateDesc *desc);
321321

322322
staticvoidAtProcExit_Files(intcode,Datumarg);
323323
staticvoidCleanupTempFiles(boolisProcExit);
324-
staticvoidRemovePgTempFilesInDir(constchar*tmpdirname,boolunlink_all);
324+
staticvoidRemovePgTempFilesInDir(constchar*tmpdirname,boolmissing_ok,
325+
boolunlink_all);
325326
staticvoidRemovePgTempRelationFiles(constchar*tsdirname);
326327
staticvoidRemovePgTempRelationFilesInDbspace(constchar*dbspacedirname);
327328
staticboollooks_like_temp_rel_name(constchar*name);
@@ -3010,7 +3011,7 @@ RemovePgTempFiles(void)
30103011
* First process temp files in pg_default ($PGDATA/base)
30113012
*/
30123013
snprintf(temp_path,sizeof(temp_path),"base/%s",PG_TEMP_FILES_DIR);
3013-
RemovePgTempFilesInDir(temp_path, false);
3014+
RemovePgTempFilesInDir(temp_path,true,false);
30143015
RemovePgTempRelationFiles("base");
30153016

30163017
/*
@@ -3026,7 +3027,7 @@ RemovePgTempFiles(void)
30263027

30273028
snprintf(temp_path,sizeof(temp_path),"pg_tblspc/%s/%s/%s",
30283029
spc_de->d_name,TABLESPACE_VERSION_DIRECTORY,PG_TEMP_FILES_DIR);
3029-
RemovePgTempFilesInDir(temp_path, false);
3030+
RemovePgTempFilesInDir(temp_path,true,false);
30303031

30313032
snprintf(temp_path,sizeof(temp_path),"pg_tblspc/%s/%s",
30323033
spc_de->d_name,TABLESPACE_VERSION_DIRECTORY);
@@ -3040,26 +3041,37 @@ RemovePgTempFiles(void)
30403041
* DataDir as well.
30413042
*/
30423043
#ifdefEXEC_BACKEND
3043-
RemovePgTempFilesInDir(PG_TEMP_FILES_DIR, false);
3044+
RemovePgTempFilesInDir(PG_TEMP_FILES_DIR,true,false);
30443045
#endif
30453046
}
30463047

30473048
/*
3048-
* Process one pgsql_tmp directory for RemovePgTempFiles. At the top level in
3049-
* each tablespace, this should be called with unlink_all = false, so that
3049+
* Process one pgsql_tmp directory for RemovePgTempFiles.
3050+
*
3051+
* If missing_ok is true, it's all right for the named directory to not exist.
3052+
* Any other problem results in a LOG message. (missing_ok should be true at
3053+
* the top level, since pgsql_tmp directories are not created until needed.)
3054+
*
3055+
* At the top level, this should be called with unlink_all = false, so that
30503056
* only files matching the temporary name prefix will be unlinked. When
30513057
* recursing it will be called with unlink_all = true to unlink everything
30523058
* under a top-level temporary directory.
3059+
*
3060+
* (These two flags could be replaced by one, but it seems clearer to keep
3061+
* them separate.)
30533062
*/
30543063
staticvoid
3055-
RemovePgTempFilesInDir(constchar*tmpdirname,boolunlink_all)
3064+
RemovePgTempFilesInDir(constchar*tmpdirname,boolmissing_ok,boolunlink_all)
30563065
{
30573066
DIR*temp_dir;
30583067
structdirent*temp_de;
30593068
charrm_path[MAXPGPATH*2];
30603069

30613070
temp_dir=AllocateDir(tmpdirname);
30623071

3072+
if (temp_dir==NULL&&errno==ENOENT&&missing_ok)
3073+
return;
3074+
30633075
while ((temp_de=ReadDirExtended(temp_dir,tmpdirname,LOG))!=NULL)
30643076
{
30653077
if (strcmp(temp_de->d_name,".")==0||
@@ -3087,7 +3099,7 @@ RemovePgTempFilesInDir(const char *tmpdirname, bool unlink_all)
30873099
if (S_ISDIR(statbuf.st_mode))
30883100
{
30893101
/* recursively remove contents, then directory itself */
3090-
RemovePgTempFilesInDir(rm_path, true);
3102+
RemovePgTempFilesInDir(rm_path,false,true);
30913103

30923104
if (rmdir(rm_path)<0)
30933105
ereport(LOG,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp