Skip to content

Commit 0177f43

Browse files
committed
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.
1 parent 23671f5 commit 0177f43

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.415 2004/07/24 20:01:42 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.416 2004/07/27 01:46:03 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -1154,12 +1154,13 @@ ServerLoop(void)
11541154

11551155
if (selres < 0)
11561156
{
1157-
if (errno == EINTR || errno == EWOULDBLOCK)
1158-
continue;
1159-
ereport(LOG,
1160-
(errcode_for_socket_access(),
1161-
errmsg("select() failed in postmaster: %m")));
1162-
return STATUS_ERROR;
1157+
if (errno != EINTR && errno != EWOULDBLOCK)
1158+
{
1159+
ereport(LOG,
1160+
(errcode_for_socket_access(),
1161+
errmsg("select() failed in postmaster: %m")));
1162+
return STATUS_ERROR;
1163+
}
11631164
}
11641165

11651166
/*
@@ -2014,6 +2015,11 @@ reaper(SIGNAL_ARGS)
20142015
* We expect that it wrote a shutdown checkpoint. (If
20152016
* for some reason it didn't, recovery will occur on next
20162017
* postmaster start.)
2018+
*
2019+
* Note: we do not wait around for exit of the archiver or
2020+
* stats processes. They've been sent SIGQUIT by this
2021+
* point, and in any case contain logic to commit hara-kiri
2022+
* if they notice the postmaster is gone.
20172023
*/
20182024
ExitPostmaster(0);
20192025
}
@@ -2095,6 +2101,12 @@ reaper(SIGNAL_ARGS)
20952101
/* And tell it to shut down */
20962102
if (BgWriterPID != 0)
20972103
kill(BgWriterPID, SIGUSR2);
2104+
/* Tell pgarch to shut down too; nothing left for it to do */
2105+
if (PgArchPID != 0)
2106+
kill(PgArchPID, SIGQUIT);
2107+
/* Tell pgstat to shut down too; nothing left for it to do */
2108+
if (PgStatPID != 0)
2109+
kill(PgStatPID, SIGQUIT);
20982110
}
20992111

21002112
reaper_done:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy