Fix running out of file descriptors for spill files.
authorAmit Kapila <[email protected]>
Thu, 2 Jan 2020 06:58:02 +0000 (12:28 +0530)
committerAmit Kapila <[email protected]>
Thu, 2 Jan 2020 07:08:29 +0000 (12:38 +0530)
commit1ad47e8757bb95058e70fd00d5e619833c83df40
treec8dc235347b68bf78af33ead2062b972cf407632
parentce758a3d753748891ba2dbd56ad7953154e256d2
Fix running out of file descriptors for spill files.

Currently while decoding changes, if the number of changes exceeds a
certain threshold, we spill those to disk.  And this happens for each
(sub)transaction.  Now, while reading all these files, we don't close them
until we read all the files.  While reading these files, if the number of
such files exceeds the maximum number of file descriptors, the operation
errors out.

Use PathNameOpenFile interface to open these files as that internally has
the mechanism to release kernel FDs as needed to get us under the
max_safe_fds limit.

Reported-by: Amit Khandekar
Author: Amit Khandekar
Reviewed-by: Amit Kapila
Backpatch-through: 9.4
Discussion: https://postgr.es/m/CAJ3gD9c-sECEn79zXw4yBnBdOttacoE-6gAyP0oy60nfs_sabQ@mail.gmail.com
src/backend/replication/logical/reorderbuffer.c