Maintain valid md.c state when FileClose() fails.
authorNoah Misch <noah@leadboat.com>
Sat, 11 Jan 2020 02:31:22 +0000 (18:31 -0800)
committerNoah Misch <noah@leadboat.com>
Sat, 11 Jan 2020 02:31:22 +0000 (18:31 -0800)
commit38fc056074e034087af8a1589507631682a279d1
treef35458711bedf324611e144fa5d55cef01b42339
parent1a4a0329650b0545a54afb3c317aa289fd817f8a
Maintain valid md.c state when FileClose() fails.

FileClose() failure ordinarily causes a PANIC.  Suppose the user
disables that PANIC via data_sync_retry=on.  After mdclose() issued a
FileClose() that failed, calls into md.c raised SIGSEGV.  This fix adds
repalloc() calls during mdclose(); update a comment about ignoring
repalloc() cost.  The rate of relation segment count change is a minor
factor; more relevant to overall performance is the rate of mdclose()
and subsequent re-opening of segments.  Back-patch to v10, where commit
45e191e3aa62d47a8bc1a33f784286b2051f45cb introduced the bug.

Reviewed by Kyotaro Horiguchi.

Discussion: https://postgr.es/m/20191222091930.GA1280238@rfd.leadboat.com
src/backend/storage/smgr/md.c