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

From Andres Freund
Subject Re: get_controlfile() can leak fds in the backend
Date
Msg-id 20190228210723.qmjuh2mrifcb37wb@alap3.anarazel.de
Whole thread Raw
In response to Re: get_controlfile() can leak fds in the backend  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: get_controlfile() can leak fds in the backend
List pgsql-hackers
Hi,

On 2019-02-28 09:54:48 +0100, Fabien COELHO wrote:
> > If we were to want to do more here, ISTM the right approach would use
> > the postmaster pid file, not the control file.
> 
> ISTM that this just means re-inventing a manual poor-featured
> race-condition-prone lock API around another file, which seems to be created
> more or less only by "pg_ctl", while some other commands use the control
> file (eg pg_rewind, AFAICS).

Huh? Postmaster.pid is written by the backend, pg_ctl just checks it to
see if the backend has finished starting up etc. It's precisely what the
backend uses to prevent two postmasters to start etc. It's also what say
pg_resetwal checks to protect against a concurrently running lcuster
(albeit in a racy way). If we want to make things more bulletproof,
that's the place.  The control file is constantly written to, sometimes
by different processes, it'd just not be a good file for such lockout
mechanisms.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Drop type "smgr"?
Next
From: Joe Conway
Date:
Subject: Re: get_controlfile() can leak fds in the backend