Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Date
Msg-id 20230922.161551.320043332510268554.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses RE: pg_ctl start may return 0 even if the postmaster has been already started on Windows
List pgsql-hackers
At Wed, 20 Sep 2023 14:18:41 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in 
> I was able to see the trouble in the CI environment, but not
> locally. I'll delve deeper into this. Thanks you for bringing it to my
> attention.

I found two instances with multiple child processes.

# child-pid / parent-pid / given-pid : exec name
process  parent PID  child PID  target PID   exec file
shell       1228       6472        1228      cmd.exe
child       5184       1228        1228      cmd.exe
child       6956       1228        1228      postgres.exe
> launcher shell executed multiple processes

process  parent PID  child PID  target PID   exec file
shell       4296       5880        4296      cmd.exe
child       5156       4296        4296      agent.exe
child       5640       4296        4296      postgres.exe
> launcher shell executed multiple processes

It looks like the environment has autorun setups for cmd.exe. There's
another known issue related to auto-launching chcp at
startup. Ideally, we would avoid such behavior in the
postmaster-launcher shell.  I think we should add "/D" flag to cmd.exe
command line, perhaps in a separate patch.

Even after making that change, I still see something being launched from the launcher cmd.exe...

process  parent PID  child PID  target PID   exec file
shell       2784       6668        2784      cmd.exe
child       6140       2784        2784      MicrosoftEdgeUpdate.exe
child       6260       2784        2784      postgres.exe
> launcher shell executed multiple processes

I'm not sure what triggers this; perhaps some other kind of hooks?  If
we cannot avoid this behavior, we'll have to verify the executable
file name. It should be fine, given that the file name is constant,
but I'm not fully convinced that this is the ideal solution.

Another issue is.. that I haven't been able to cause the false
positive of pg_ctl start..  Do you have a concise reproducer of the
issue?

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [PoC] pg_upgrade: allow to upgrade publisher node
Next
From: Ashutosh Bapat
Date:
Subject: Re: Infinite Interval