Re: get_controlfile() can leak fds in the backend - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: get_controlfile() can leak fds in the backend
Date
Msg-id 20190301010042.GB1348@paquier.xyz
Whole thread Raw
In response to Re: get_controlfile() can leak fds in the backend  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
On Thu, Feb 28, 2019 at 04:09:32PM -0500, Joe Conway wrote:
> Committed and push that way.

Thanks for committing a fix.

> By the way, while looking at this, I noted at least a couple of places
> where OpenTransientFile() is being passed O_RDWR when the usage is
> pretty clearly intended to be read-only. For example at least two
> instances in slru.c -- SlruPhysicalReadPage() and
> SimpleLruDoesPhysicalPageExist(). Is it worth while searching for and
> fixing those instances?

There are roughly 40~42 callers of OpenTransientFile().  Looking at
them I can see that RestoreSlotFromDisk() could also switch to RDONLY
instead of RDWR.  I am also a bit tired of the lack error handling
around CloseTransientFile().  While in some code paths the file
descriptors are closed for an error, in some others we should report
something.  I am going to send a patch after a lookup.  Let's see all
that on a separate thread.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: jsonpath
Next
From: Michael Paquier
Date:
Subject: Re: get_controlfile() can leak fds in the backend