From: Noah Misch <noah@leadboat.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: michael@paquier.xyz
Cc: robertmhaas@gmail.com
Cc: kuroda.hayato@fujitsu.com
Cc: shlok.kyal.oss@gmail.com
Cc: pgsql-hackers@lists.postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Date: Sat, 29 Jun 2024 19:12:11 -0700
Message-ID: <20240630021211.f3.nmisch@google.com> (raw)
In-Reply-To: <20240606.172146.1104070889615683903.horikyota.ntt@gmail.com>
References: <Zl5SC_kboY7i0AS8@paquier.xyz>
<20240606.164500.1165061072372246513.horikyota.ntt@gmail.com>
<20240606.171515.1237539015915565828.horikyota.ntt@gmail.com>
<20240606.172146.1104070889615683903.horikyota.ntt@gmail.com>
On Thu, Jun 06, 2024 at 05:21:46PM +0900, Kyotaro Horiguchi wrote:
> At Thu, 06 Jun 2024 17:15:15 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in
> > By the way, the need to shift by 2 seconds to tolerate clock skew
> > suggests that the current launcher-postmaster association mechanism is
> > somewhat unreliable. Couldn't we add a command line option to
> > postmaster to explicitly pass a unique identifier (say, pid itself) of
> > the launcher? If it is not specified, the number should be the PID of
> > the immediate parent process.
>
> No. The combination of pg_ctl's pid and timestamp, to avoid false
> matching during reboot.
>
> > This change avoids the need for the special treatment for Windows.
Regarding your "unique identifier" idea, pg_ctl could generate an 8-byte
random value for the postmaster to write to postmaster.pid. That would be
enough for wait_for_postmaster_start() to ignore PIDs and achieve its mission
without OS-specific code.
Commits 9886744 and b83747a added /D to two %comspec% callers. I gather they
arose to make particular cmd.exe invocations have just one child. However,
http://postgr.es/m/20240111.173322.1809044112677090191.horikyota.ntt@gmail.com
reports multiple children remain possible. v17 is currently in a weird state
where most Windows subprocess invocation routes through pgwin32_system() and
does not add /D, while these two callers add /D. I suspect we should either
(1) prepend /D in pgwin32_system() and other %comspec% usage or (2) revert
prepending it in the callers from this thread's commits. While
"Software\Microsoft\Command Processor\AutoRun" is hard to use without breaking
things, it's not PostgreSQL's job to second-guess the user in that respect.
Hence, I lean toward (2). What do you think?
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: noah@leadboat.com, horikyota.ntt@gmail.com, michael@paquier.xyz, robertmhaas@gmail.com, kuroda.hayato@fujitsu.com, shlok.kyal.oss@gmail.com, pgsql-hackers@lists.postgresql.org, tgl@sss.pgh.pa.us
Subject: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
In-Reply-To: <20240630021211.f3.nmisch@google.com>
* 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