"Mark Steben" <msteben@autorevenue.com> writes:
> Is it possible that, during startup, postmaster.pid takes a second or two to
> be created and hadn't been created yet when the test was run?
It's not instantaneous, for sure. For one thing, the kernel could be
scheduling the postmaster at lower priority than the continued execution
of your startup script. If you don't have any sleep at all in there
then the risk of failure would be quite high, even assuming the
postmaster would create the pidfile instantaneously once it gets to run.
And there are other things it has to do first, like read the config file
so it knows where the data directory is ...
Since you say you're using pg_ctl, why don't you use its -w option and
not let the script proceed until you know the postmaster is up?
regards, tom lane