I wrote: > "Kevin Grittner" <kevin.gritt...@wicourts.gov> writes: >> ... This would allow pg_ctl or a script to >> connect to a port and see if it is the expected postmaster process.
> I would rather see us implement the hypothetical pg_ping protocol > and remember to include the postmaster's PID in the response. Although on second thought, any such test is worth approximately nothing anyway. You can check that the postmaster answering the doorbell reports the same PID that you see in $PGDATA/postmaster.pid, but that still doesn't prove that that postmaster is using that data directory. It could be a random coincidence of PIDs. And in the case of a start script, the probability of random PID match to a stale lockfile is many orders of magnitude higher than you might think; see prior discussions. This could be addressed by having the postmaster report its $PGDATA value in the pg_ping response, but I would be against that on security grounds. We don't let nonprivileged users know where PGDATA is, why would we make the information available without any authentication at all? [ thinks... ] Maybe we could have the postmaster generate a random number at start and include that in both the postmaster.ports file and its pg_ping responses. That would have a substantially lower collision probability than PID, if the number generation process were well designed; and it wouldn't risk exposing anything sensitive in the ping response. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs