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

Commit7c85be0

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 parent7bb3102 commit7c85be0

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
@@ -1280,19 +1280,16 @@ int
12801280
mdsyncfiletag(constFileTag*ftag,char*path)
12811281
{
12821282
SMgrRelationreln=smgropen(ftag->rnode,InvalidBackendId);
1283-
intfd,
1284-
result,
1285-
save_errno;
1283+
Filefile;
12861284
boolneed_to_close;
1285+
intresult,
1286+
save_errno;
12871287

12881288
/* See if we already have the file open, or need to open it. */
12891289
if (ftag->segno<reln->md_num_open_segs[ftag->forknum])
12901290
{
1291-
Filefile;
1292-
12931291
file=reln->md_seg_fds[ftag->forknum][ftag->segno].mdfd_vfd;
12941292
strlcpy(path,FilePathName(file),MAXPGPATH);
1295-
fd=FileGetRawDesc(file);
12961293
need_to_close= false;
12971294
}
12981295
else
@@ -1303,24 +1300,20 @@ mdsyncfiletag(const FileTag *ftag, char *path)
13031300
strlcpy(path,p,MAXPGPATH);
13041301
pfree(p);
13051302

1306-
fd=OpenTransientFile(path,O_RDWR);
1307-
if (fd<0)
1303+
file=PathNameOpenFile(path,O_RDWR |PG_BINARY);
1304+
if (file<0)
13081305
return-1;
13091306
need_to_close= true;
13101307
}
13111308

13121309
/* Sync the file. */
1313-
pgstat_report_wait_start(WAIT_EVENT_DATA_FILE_SYNC);
1314-
result=pg_fsync(fd);
1310+
result=FileSync(file,WAIT_EVENT_DATA_FILE_SYNC);
13151311
save_errno=errno;
1316-
pgstat_report_wait_end();
13171312

1318-
if (need_to_close&&CloseTransientFile(fd)!=0)
1319-
ereport(WARNING,
1320-
(errcode_for_file_access(),
1321-
errmsg("could not close file \"%s\": %m",path)));
1322-
errno=save_errno;
1313+
if (need_to_close)
1314+
FileClose(file);
13231315

1316+
errno=save_errno;
13241317
returnresult;
13251318
}
13261319

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp