Re: get_controlfile() can leak fds in the backend
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>, Joe Conway <mail@joeconway.com>
Date: 2019-02-28T21:07:23Z
Lists: 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
Commits
-
Tighten use of OpenTransientFile and CloseTransientFile
- 82a5649fb9db 12.0 landed
-
Make get_controlfile not leak file descriptors
- 4598a99cf22d 12.0 landed