Re: pg_ctl and port number detection - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_ctl and port number detection
Date
Msg-id 4559.1292714494@sss.pgh.pa.us
Whole thread Raw
In response to Re: pg_ctl and port number detection  (Bruce Momjian <bruce@momjian.us>)
Responses Re: pg_ctl and port number detection  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> Tom Lane wrote:
>> Bruce Momjian <bruce@momjian.us> writes:
>>> pg_ctl already knows the data directory.  If the file is missing, the
>>> server is not running.  If the file exists, the first number on the last
>>> line, divided by 1000, is the port number.

>> That's somewhere between fragile and outright wrong.

> Please explain why my idea is not an improvement.

Because it's assuming that those numbers are sysv shmem keys derived in
a particular way.  We have platforms on which that is wrong, Windows
being the most obvious example.  Reading the shmem key assignment code
closely will suggest to you other ways that this could fail.  Not to
mention that people propose getting rid of sysv shmem approximately
every other month, and perhaps someday that will actually happen;
whereupon whatever might get logged in postmaster.pid could be something
completely different.

If you really think that pulling a port number out of the pid file is an
improvement over what pg_ctl does now, then you need to start by storing
the port number, as such, in the pid file.  Not something that might or
might not be related to the port number.  But what we have to discuss
before that is whether we mind having a significant postmaster version
dependency in pg_ctl.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: pg_ctl and port number detection
Next
From: Bruce Momjian
Date:
Subject: Re: pg_ctl and port number detection