Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: kuroda(dot)hayato(at)fujitsu(dot)com
Cc: michael(at)paquier(dot)xyz, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Date: 2023-09-08 05:17:16
Message-ID: 20230908.141716.1245636448942130750.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 7 Sep 2023 10:53:41 +0000, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> wrote in
> My first idea is that to move the checking part to above, but this may not handle
> the case the postmaster is still alive (now sure this is real issue). Do we have to
> add a new indicator which ensures the identity of processes for windows?
> Please tell me how you feel.

It doesn't seem to work as expected. We still lose the relationship
between the PID file and the launched postmaster.

> > Now, I
> > also recall that the processes spawned by pg_ctl on Windows make the
> > status handling rather tricky to reason about..
>
> Did you say about the below comment? Currently I have no idea to make
> codes more proper, sorry.
>
> ```
> * On Windows, we may be checking the postmaster's parent shell, but
> * that's fine for this purpose.
> ```

Ditching cmd.exe seems like a big hassle. So, on the flip side, I
tried to identify the postmaster PID using the shell's PID, and it
seem to work. The APIs used are avaiable from XP/2003 onwards.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
pg_ctl_waits_for_postmasters_pid_on_windows.patch text/x-patch 3.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-09-08 05:21:44 Re: old_snapshot_threshold bottleneck on replica
Previous Message Lepikhov Andrei 2023-09-08 05:11:31 Re: Optimize planner memory consumption for huge arrays