Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> Here is a proposal. It waits separately for the pid file to appear and
> also checks for the sleep query to be registered by the backend, so it
> doesn't have any more dependencies on things happening "fast enough".
> And it's also faster in the normal case now. Thoughts?
That looks pretty solid to me, and I can confirm that it passes
on wrasse's host. The only nit I can find to pick is that this:
+ usleep(10_000) until -s "$tempdir/psql.pid" or ($count++ > 180 * 100 and die 'pid file did not appear');
basically assumes that psql.pid will be written atomically.
It'd be marginally safer to wait till psql.pid can be seen to
contain a newline. I don't think that would be too hard to do,
if you put the slurp_file call inside the wait loop and inspect
its result.
regards, tom lane