pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_regress: promptly detect failed postmaster startup
2+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2018-12-31 94600dd4f4 ca01a6748d 7c97b0f55e 13602a9b6b 2fe431f1be 309d16f073  pg_regress: Promptly detect failed postmaster startup.
* pg_regress: promptly detect failed postmaster startup
@ 2018-12-31 17:29  Noah Misch <noah@leadboat.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Noah Misch @ 2018-12-31 17:29 UTC (permalink / raw)
  To: pgsql-hackers

When "make check TEMP_CONFIG=<(echo break_me=on)" spawns a postmaster that
fails startup, we detect that with "pg_regress: postmaster did not respond
within 60 seconds".  pg_regress has a kill(postmaster_pid, 0) intended to
detect this case faster.  Since kill(ZOMBIE-PID, 0) succeeds[1], that test is
ineffective.  The fix, attached, is to instead test waitpid(), like pg_ctl's
wait_for_postmaster() does.

[1] Search for "zombie" in
http://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html

Attachments:

pg_regress-dead-postmaster-v1.patch (text/x-diff, 535B) download diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 63fe689..2c46941 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -2414,7 +2414,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc * Fail immediately if postmaster has exited */ #ifndef WIN32 - if (kill(postmaster_pid, 0) != 0) + if (waitpid(postmaster_pid, NULL, WNOHANG) == postmaster_pid) #else if (WaitForSingleObject(postmaster_pid, 0) == WAIT_OBJECT_0) #endif
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: pg_regress: promptly detect failed postmaster startup
@ 2018-12-31 18:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-12-31 18:51 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: pgsql-hackers

Noah Misch <noah@leadboat.com> writes:
> When "make check TEMP_CONFIG=<(echo break_me=on)" spawns a postmaster that
> fails startup, we detect that with "pg_regress: postmaster did not respond
> within 60 seconds".  pg_regress has a kill(postmaster_pid, 0) intended to
> detect this case faster.  Since kill(ZOMBIE-PID, 0) succeeds[1], that test is
> ineffective.

Ooops.

> The fix, attached, is to instead test waitpid(), like pg_ctl's
> wait_for_postmaster() does.

+1.  This leaves postmaster_pid as a dangling pointer, but since
we just exit immediately, that seems fine.  (If we continued, and
arrived at the "kill(postmaster_pid, SIGKILL)" below, it would not
be fine.)

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-12-31 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-31 17:29 pg_regress: promptly detect failed postmaster startup Noah Misch <noah@leadboat.com>
2018-12-31 18:51 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox