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

Commitcb97742

Browse files
committed
Maintain valid md.c state when FileClose() fails.
FileClose() failure ordinarily causes a PANIC. Suppose the userdisables that PANIC via data_sync_retry=on. After mdclose() issued aFileClose() that failed, calls into md.c raised SIGSEGV. This fix addsrepalloc() calls during mdclose(); update a comment about ignoringrepalloc() cost. The rate of relation segment count change is a minorfactor; more relevant to overall performance is the rate of mdclose()and subsequent re-opening of segments. Back-patch to v10, where commit45e191e introduced the bug.Reviewed by Kyotaro Horiguchi.Discussion:https://postgr.es/m/20191222091930.GA1280238@rfd.leadboat.com
1 parent7b84ff3 commitcb97742

File tree

1 file changed

+6
-14
lines changed
  • src/backend/storage/smgr

1 file changed

+6
-14
lines changed

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -639,18 +639,10 @@ mdclose(SMgrRelation reln, ForkNumber forknum)
639639
{
640640
MdfdVec*v=&reln->md_seg_fds[forknum][nopensegs-1];
641641

642-
/* if not closed already */
643-
if (v->mdfd_vfd >=0)
644-
{
645-
FileClose(v->mdfd_vfd);
646-
v->mdfd_vfd=-1;
647-
}
648-
642+
FileClose(v->mdfd_vfd);
643+
_fdvec_resize(reln,forknum,nopensegs-1);
649644
nopensegs--;
650645
}
651-
652-
/* resize just once, avoids pointless reallocations */
653-
_fdvec_resize(reln,forknum,0);
654646
}
655647

656648
/*
@@ -1774,10 +1766,10 @@ _fdvec_resize(SMgrRelation reln,
17741766
else
17751767
{
17761768
/*
1777-
* It doesn't seem worthwhile complicating the codeby having a more
1778-
*aggressive growth strategy here; the number of segments doesn't
1779-
*grow that fast, and the memory context internally will sometimes
1780-
*avoiddoing an actual reallocation.
1769+
* It doesn't seem worthwhile complicating the codeto amortize
1770+
*repalloc() calls. Those are far faster than PathNameOpenFile() or
1771+
*FileClose(), and the memory context internally will sometimes avoid
1772+
* doing an actual reallocation.
17811773
*/
17821774
reln->md_seg_fds[forknum]=
17831775
repalloc(reln->md_seg_fds[forknum],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp