Skip to content
Snippets Groups Projects
Commit 0177f430 authored by Tom Lane's avatar Tom Lane
Browse files

Fix oversight: in case where SIGTERM is received while there are

live backends, the archiver and stats processes never got sent a
kill signal.  They'd eventually exit on their own, but not for awhile,
which is a bit annoying when you are trying to replace the executable
file on a platform that doesn't allow removal of busy executables.
Also, tweak main loop logic so that we will perform the background
tasks after select() returns EINTR.
parent 23671f5a
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.415 2004/07/24 20:01:42 tgl Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.416 2004/07/27 01:46:03 tgl Exp $
* *
* NOTES * NOTES
* *
...@@ -1154,13 +1154,14 @@ ServerLoop(void) ...@@ -1154,13 +1154,14 @@ ServerLoop(void)
if (selres < 0) if (selres < 0)
{ {
if (errno == EINTR || errno == EWOULDBLOCK) if (errno != EINTR && errno != EWOULDBLOCK)
continue; {
ereport(LOG, ereport(LOG,
(errcode_for_socket_access(), (errcode_for_socket_access(),
errmsg("select() failed in postmaster: %m"))); errmsg("select() failed in postmaster: %m")));
return STATUS_ERROR; return STATUS_ERROR;
} }
}
/* /*
* New connection pending on any of our sockets? If so, fork a * New connection pending on any of our sockets? If so, fork a
...@@ -2014,6 +2015,11 @@ reaper(SIGNAL_ARGS) ...@@ -2014,6 +2015,11 @@ reaper(SIGNAL_ARGS)
* We expect that it wrote a shutdown checkpoint. (If * We expect that it wrote a shutdown checkpoint. (If
* for some reason it didn't, recovery will occur on next * for some reason it didn't, recovery will occur on next
* postmaster start.) * postmaster start.)
*
* Note: we do not wait around for exit of the archiver or
* stats processes. They've been sent SIGQUIT by this
* point, and in any case contain logic to commit hara-kiri
* if they notice the postmaster is gone.
*/ */
ExitPostmaster(0); ExitPostmaster(0);
} }
...@@ -2095,6 +2101,12 @@ reaper(SIGNAL_ARGS) ...@@ -2095,6 +2101,12 @@ reaper(SIGNAL_ARGS)
/* And tell it to shut down */ /* And tell it to shut down */
if (BgWriterPID != 0) if (BgWriterPID != 0)
kill(BgWriterPID, SIGUSR2); kill(BgWriterPID, SIGUSR2);
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
} }
reaper_done: reaper_done:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment