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

Commit7bb3102

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 parenta7ee7c8 commit7bb3102

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
@@ -1280,25 +1280,48 @@ int
12801280
mdsyncfiletag(constFileTag*ftag,char*path)
12811281
{
12821282
SMgrRelationreln=smgropen(ftag->rnode,InvalidBackendId);
1283-
MdfdVec*v;
1284-
char*p;
1283+
intfd,
1284+
result,
1285+
save_errno;
1286+
boolneed_to_close;
12851287

1286-
/* Provide the path for informational messages. */
1287-
p=_mdfd_segpath(reln,ftag->forknum,ftag->segno);
1288-
strlcpy(path,p,MAXPGPATH);
1289-
pfree(p);
1288+
/* See if we already have the file open, or need to open it. */
1289+
if (ftag->segno<reln->md_num_open_segs[ftag->forknum])
1290+
{
1291+
Filefile;
1292+
1293+
file=reln->md_seg_fds[ftag->forknum][ftag->segno].mdfd_vfd;
1294+
strlcpy(path,FilePathName(file),MAXPGPATH);
1295+
fd=FileGetRawDesc(file);
1296+
need_to_close= false;
1297+
}
1298+
else
1299+
{
1300+
char*p;
1301+
1302+
p=_mdfd_segpath(reln,ftag->forknum,ftag->segno);
1303+
strlcpy(path,p,MAXPGPATH);
1304+
pfree(p);
1305+
1306+
fd=OpenTransientFile(path,O_RDWR);
1307+
if (fd<0)
1308+
return-1;
1309+
need_to_close= true;
1310+
}
1311+
1312+
/* Sync the file. */
1313+
pgstat_report_wait_start(WAIT_EVENT_DATA_FILE_SYNC);
1314+
result=pg_fsync(fd);
1315+
save_errno=errno;
1316+
pgstat_report_wait_end();
1317+
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;
12901323

1291-
/* Try to open the requested segment. */
1292-
v=_mdfd_getseg(reln,
1293-
ftag->forknum,
1294-
ftag->segno* (BlockNumber)RELSEG_SIZE,
1295-
false,
1296-
EXTENSION_RETURN_NULL |EXTENSION_DONT_CHECK_SIZE);
1297-
if (v==NULL)
1298-
return-1;
1299-
1300-
/* Try to fsync the file. */
1301-
returnFileSync(v->mdfd_vfd,WAIT_EVENT_DATA_FILE_SYNC);
1324+
returnresult;
13021325
}
13031326

13041327
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp