From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: mdclose() does not cope w/ FileClose() failure |
Date: | 2019-12-22 20:21:00 |
Message-ID: | 20191222202100.GA1290738@rfd.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Dec 22, 2019 at 01:19:30AM -0800, Noah Misch wrote:
> I am inclined to fix this by decrementing md_num_open_segs before modifying
> md_seg_fds (second attachment).
That leaked memory, since _fdvec_resize() assumes md_num_open_segs is also the
allocated array length. The alternative is looking better:
> An alternative would be to call
> _fdvec_resize() after every FileClose(), like mdtruncate() does; however, the
> repalloc() overhead could be noticeable. (mdclose() is called much more
> frequently than mdtruncate().)
I can skip repalloc() when the array length decreases, to assuage mdclose()'s
worry. In the mdclose() case, the final _fdvec_resize(reln, fork, 0) will
still pfree() the array. Array elements that mdtruncate() frees today will
instead persist to end of transaction. That is okay, since mdtruncate()
crossing more than one segment boundary is fairly infrequent. For it to
happen, you must either create a >2G relation and then TRUNCATE it in the same
transaction, or VACUUM must find >1-2G of unused space at the end of the
relation. I'm now inclined to do it that way, attached.
Attachment | Content-Type | Size |
---|---|---|
mdclose-FileClose-v2.patch | text/plain | 1.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | legrand legrand | 2019-12-22 20:22:50 | Re: Implementing Incremental View Maintenance |
Previous Message | Pavel Stehule | 2019-12-22 18:50:22 | Re: proposal: schema variables |