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

Commitfd005e1

Browse files
committed
Fix mdsyncfiletag(), take II.
The previous commit failed to consider that FileGetRawDesc() mightnot return a valid fd, as discovered on the build farm. Switch tousing the File interface only.Back-patch to 12, like the previous commit.
1 parentc3dc0cd commitfd005e1

File tree

1 file changed

+9
-16
lines changed
  • src/backend/storage/smgr

1 file changed

+9
-16
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,19 +1258,16 @@ int
12581258
mdsyncfiletag(constFileTag*ftag,char*path)
12591259
{
12601260
SMgrRelationreln=smgropen(ftag->rnode,InvalidBackendId);
1261-
intfd,
1262-
result,
1263-
save_errno;
1261+
Filefile;
12641262
boolneed_to_close;
1263+
intresult,
1264+
save_errno;
12651265

12661266
/* See if we already have the file open, or need to open it. */
12671267
if (ftag->segno<reln->md_num_open_segs[ftag->forknum])
12681268
{
1269-
Filefile;
1270-
12711269
file=reln->md_seg_fds[ftag->forknum][ftag->segno].mdfd_vfd;
12721270
strlcpy(path,FilePathName(file),MAXPGPATH);
1273-
fd=FileGetRawDesc(file);
12741271
need_to_close= false;
12751272
}
12761273
else
@@ -1281,24 +1278,20 @@ mdsyncfiletag(const FileTag *ftag, char *path)
12811278
strlcpy(path,p,MAXPGPATH);
12821279
pfree(p);
12831280

1284-
fd=OpenTransientFile(path,O_RDWR);
1285-
if (fd<0)
1281+
file=PathNameOpenFile(path,O_RDWR |PG_BINARY);
1282+
if (file<0)
12861283
return-1;
12871284
need_to_close= true;
12881285
}
12891286

12901287
/* Sync the file. */
1291-
pgstat_report_wait_start(WAIT_EVENT_DATA_FILE_SYNC);
1292-
result=pg_fsync(fd);
1288+
result=FileSync(file,WAIT_EVENT_DATA_FILE_SYNC);
12931289
save_errno=errno;
1294-
pgstat_report_wait_end();
12951290

1296-
if (need_to_close&&CloseTransientFile(fd)!=0)
1297-
ereport(WARNING,
1298-
(errcode_for_file_access(),
1299-
errmsg("could not close file \"%s\": %m",path)));
1300-
errno=save_errno;
1291+
if (need_to_close)
1292+
FileClose(file);
13011293

1294+
errno=save_errno;
13021295
returnresult;
13031296
}
13041297

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp