From: Joe Conway <mail@joeconway.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make get_controlfile not leak file descriptors
Date: Thu, 28 Feb 2019 20:58:50 +0000
Message-ID: <E1gzSlW-0002Bf-6v@gemulon.postgresql.org> (raw)
Make get_controlfile not leak file descriptors
When backend functions were added to expose controldata via SQL,
reading of pg_control was consolidated under src/common so that
both frontend and backend could share the same code. That move
from frontend-only to shared frontend-backend failed to recognize
the risk (and coding standards violation) of using a bare open().
In particular, it risked leaking file descriptors if transient
errors occurred while reading the file. Fix that by using
OpenTransientFile() instead in the backend case, which is
purpose-built for this type of usage.
Since there have been no complaints from the field, and an intermittent
failure low risk, no backpatch. Hard failure would of course be bad, but
in that case these functions are probably the least of your worries.
Author: Joe Conway
Reviewed-By: Michael Paquier
Reported by: Michael Paquier
Discussion: https://postgr.es/m/20190227074728.GA15710@paquier.xyz
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4598a99cf22de0dbab975d9c87ce16fd53146aca
Modified Files
--------------
src/common/controldata_utils.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: mail@joeconway.com
Subject: Re: pgsql: Make get_controlfile not leak file descriptors
In-Reply-To: <E1gzSlW-0002Bf-6v@gemulon.postgresql.org>
References: <E1gzSlW-0002Bf-6v@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox