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

Commitc3dc0cd

Browse files
committed
Don't use _mdfd_getseg() in mdsyncfiletag().
_mdfd_getseg() opens all segments up to the requested one. Thatcauses problems for mdsyncfiletag(), if mdunlinkfork() hasalready unlinked other segment files. Open the file we wantdirectly by name instead, if it's not already open.The consequence of this bug was a rare panic in the checkpointer,made more likely if you saturated the sync request queue so thatthe SYNC_FORGET_REQUEST messages for a given relation were morelikely to be absorbed in separate cycles by the checkpointer.Back-patch to 12. Defect in commit3eb77eb.Author: Thomas MunroReported-by: Justin PryzbyDiscussion:https://postgr.es/m/20191119115759.GI30362%40telsasoft.com
1 parent70c4f50 commitc3dc0cd

File tree

1 file changed

+40
-17
lines changed
  • src/backend/storage/smgr

1 file changed

+40
-17
lines changed

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

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,25 +1258,48 @@ int
12581258
mdsyncfiletag(constFileTag*ftag,char*path)
12591259
{
12601260
SMgrRelationreln=smgropen(ftag->rnode,InvalidBackendId);
1261-
MdfdVec*v;
1262-
char*p;
1261+
intfd,
1262+
result,
1263+
save_errno;
1264+
boolneed_to_close;
12631265

1264-
/* Provide the path for informational messages. */
1265-
p=_mdfd_segpath(reln,ftag->forknum,ftag->segno);
1266-
strlcpy(path,p,MAXPGPATH);
1267-
pfree(p);
1266+
/* See if we already have the file open, or need to open it. */
1267+
if (ftag->segno<reln->md_num_open_segs[ftag->forknum])
1268+
{
1269+
Filefile;
1270+
1271+
file=reln->md_seg_fds[ftag->forknum][ftag->segno].mdfd_vfd;
1272+
strlcpy(path,FilePathName(file),MAXPGPATH);
1273+
fd=FileGetRawDesc(file);
1274+
need_to_close= false;
1275+
}
1276+
else
1277+
{
1278+
char*p;
1279+
1280+
p=_mdfd_segpath(reln,ftag->forknum,ftag->segno);
1281+
strlcpy(path,p,MAXPGPATH);
1282+
pfree(p);
1283+
1284+
fd=OpenTransientFile(path,O_RDWR);
1285+
if (fd<0)
1286+
return-1;
1287+
need_to_close= true;
1288+
}
1289+
1290+
/* Sync the file. */
1291+
pgstat_report_wait_start(WAIT_EVENT_DATA_FILE_SYNC);
1292+
result=pg_fsync(fd);
1293+
save_errno=errno;
1294+
pgstat_report_wait_end();
1295+
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;
12681301

1269-
/* Try to open the requested segment. */
1270-
v=_mdfd_getseg(reln,
1271-
ftag->forknum,
1272-
ftag->segno* (BlockNumber)RELSEG_SIZE,
1273-
false,
1274-
EXTENSION_RETURN_NULL |EXTENSION_DONT_CHECK_SIZE);
1275-
if (v==NULL)
1276-
return-1;
1277-
1278-
/* Try to fsync the file. */
1279-
returnFileSync(v->mdfd_vfd,WAIT_EVENT_DATA_FILE_SYNC);
1302+
returnresult;
12801303
}
12811304

12821305
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp