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

Commit9473bb9

Browse files
committed
Further thoughts about temp_file_limit patch.
Move FileClose's decrement of temporary_files_size up, so that it will beexecuted even if elog() throws an error. This is reasonable since if theunlink() fails, the fact the file is still there is not our fault, and weare going to forget about it anyhow. So we won't count it againsttemp_file_limit anymore.Update fileSize and temporary_files_size correctly in FileTruncate.We probably don't have any places that truncate temp files, but fd.csurely should not assume that.
1 parent23e5b16 commit9473bb9

File tree

1 file changed

+13
-4
lines changed
  • src/backend/storage/file

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,10 @@ FileClose(File file)
10971097
*/
10981098
vfdP->fdstate &= ~FD_TEMPORARY;
10991099

1100+
/* Subtract its size from current usage (do first in case of error) */
1101+
temporary_files_size-=vfdP->fileSize;
1102+
vfdP->fileSize=0;
1103+
11001104
if (log_temp_files >=0)
11011105
{
11021106
structstatfilestats;
@@ -1133,10 +1137,6 @@ FileClose(File file)
11331137
if (unlink(vfdP->fileName))
11341138
elog(LOG,"could not unlink file \"%s\": %m",vfdP->fileName);
11351139
}
1136-
1137-
/* Subtract its size from current usage */
1138-
temporary_files_size-=vfdP->fileSize;
1139-
vfdP->fileSize=0;
11401140
}
11411141

11421142
/* Unregister it from the resource owner */
@@ -1447,6 +1447,15 @@ FileTruncate(File file, off_t offset)
14471447
returnreturnCode;
14481448

14491449
returnCode=ftruncate(VfdCache[file].fd,offset);
1450+
1451+
if (returnCode==0&&VfdCache[file].fileSize>offset)
1452+
{
1453+
/* adjust our state for truncation of a temp file */
1454+
Assert(VfdCache[file].fdstate&FD_TEMPORARY);
1455+
temporary_files_size-=VfdCache[file].fileSize-offset;
1456+
VfdCache[file].fileSize=offset;
1457+
}
1458+
14501459
returnreturnCode;
14511460
}
14521461

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp