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

From Hayato Kuroda (Fujitsu)
Subject RE: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Date
Msg-id TYAPR01MB58662D7A48E8587A14244097F5EEA@TYAPR01MB5866.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows  (Michael Paquier <michael@paquier.xyz>)
Responses Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
List pgsql-hackers
Dear Michael,

Thank you for replying!

> Not failing on `pg_ctl start` if the command is run on a data folder
> that has already been started previously by a different command with a
> postmaster still alive feels like cheating, because pg_ctl is lying
> about its result.  If pg_ctl wants to start a cluster but is not able
> to do it, either because the postmaster failed at startup or because
> the cluster has already started, it should report a failure.

I have a same feelings as you. Users may use the return code in their batch file
and they may decide what to do based on the wrong status. Reporting the status
more accurately is nice.

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.

> 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.
```

Best Regards,
Hayato Kuroda
FUJITSU LIMITED


Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: persist logical slots to disk during shutdown checkpoint
Next
From: Ashutosh Bapat
Date:
Subject: Re: persist logical slots to disk during shutdown checkpoint