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

Commit95c4571

Browse files
Have BufFileSize() ereport() on FileSize() failure.
Move the responsibility for checking for and reporting a failure fromthe only current BufFileSize() caller, logtape.c, to BufFileSize()itself. Code within buffile.c is generally responsible for interfacingwith fd.c to report irrecoverable failures. This seems like aconvention that's worth sticking to.Reorganizing things this way makes it easy to make the error messageraised in the event of BufFileSize() failure descriptive of theunderlying problem. We're now clear on the distinction betweentemporary file name and BufFile name, and can show errno, confident thatits value actually relates to the error being reported. In passing, anexisting, similar buffile.c ereport() + errcode_for_file_access() siteis changed to follow the same conventions.The API of the function BufFileSize() is changed by this commit, despitealready being in a stable release (Postgres 11). This seems acceptable,since the BufFileSize() ABI was changed by commitaa55183, whichhasn't made it into a point release yet. Besides, it's difficult toimagine a third party BufFileSize() caller not just raising an erroranyway, since BufFile state should be considered corrupt whenBufFileSize() fails.Per complaint from Tom Lane.Discussion:https://postgr.es/m/26974.1540826748@sss.pgh.pa.usBackpatch: 11-, where shared BufFiles were introduced.
1 parent48cf918 commit95c4571

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ BufFileOpenShared(SharedFileSet *fileset, const char *name)
314314
if (nfiles==0)
315315
ereport(ERROR,
316316
(errcode_for_file_access(),
317-
errmsg("could not open BufFile \"%s\"",name)));
317+
errmsg("could not open temporary file \"%s\" from BufFile \"%s\": %m",
318+
segment_name,name)));
318319

319320
file=makeBufFileCommon(nfiles);
320321
file->files=files;
@@ -793,20 +794,26 @@ BufFileTellBlock(BufFile *file)
793794
#endif
794795

795796
/*
796-
* Return the currentfile size.
797+
* Return the currentshared BufFile size.
797798
*
798799
* Counts any holes left behind by BufFileAppend as part of the size.
799-
*Returns -1onerror.
800+
*ereport()sonfailure.
800801
*/
801802
int64
802803
BufFileSize(BufFile*file)
803804
{
804805
int64lastFileSize;
805806

807+
Assert(file->fileset!=NULL);
808+
806809
/* Get the size of the last physical file by seeking to end. */
807810
lastFileSize=FileSeek(file->files[file->numFiles-1],0,SEEK_END);
808811
if (lastFileSize<0)
809-
return-1;
812+
ereport(ERROR,
813+
(errcode_for_file_access(),
814+
errmsg("could not determine size of temporary file \"%s\" from BufFile \"%s\": %m",
815+
FilePathName(file->files[file->numFiles-1]),
816+
file->name)));
810817
file->offsets[file->numFiles-1]=lastFileSize;
811818

812819
return ((file->numFiles-1)* (int64)MAX_PHYSICAL_FILESIZE)+

‎src/backend/utils/sort/logtape.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,6 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
433433
pg_itoa(i,filename);
434434
file=BufFileOpenShared(fileset,filename);
435435
filesize=BufFileSize(file);
436-
if (filesize<0)
437-
ereport(ERROR,
438-
(errcode_for_file_access(),
439-
errmsg("could not determine size of temporary file \"%s\"",filename)));
440436

441437
/*
442438
* Stash first BufFile, and concatenate subsequent BufFiles to that.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp