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