Skip to content

Commit fb7df89

Browse files
committed
Reload config file in startup process on SIGHUP.
Fujii Masao
1 parent 820984b commit fb7df89

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.332 2009/02/23 09:28:49 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.333 2009/03/04 13:56:40 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -429,6 +429,7 @@ static bool InRedo = false;
429429
/*
430430
* Flag set by interrupt handlers for later service in the redo loop.
431431
*/
432+
static volatile sig_atomic_t got_SIGHUP = false;
432433
static volatile sig_atomic_t shutdown_requested = false;
433434
/*
434435
* Flag set when executing a restore command, to tell SIGTERM signal handler
@@ -5362,6 +5363,15 @@ StartupXLOG(void)
53625363
}
53635364
#endif
53645365

5366+
/*
5367+
* Check if we were requested to re-read config file.
5368+
*/
5369+
if (got_SIGHUP)
5370+
{
5371+
got_SIGHUP = false;
5372+
ProcessConfigFile(PGC_SIGHUP);
5373+
}
5374+
53655375
/*
53665376
* Check if we were requested to exit without finishing
53675377
* recovery.
@@ -7641,6 +7651,13 @@ startupproc_quickdie(SIGNAL_ARGS)
76417651
}
76427652

76437653

7654+
/* SIGHUP: set flag to re-read config file at next convenient time */
7655+
static void
7656+
StartupProcSigHupHandler(SIGNAL_ARGS)
7657+
{
7658+
got_SIGHUP = true;
7659+
}
7660+
76447661
/* SIGTERM: set flag to abort redo and exit */
76457662
static void
76467663
StartupProcShutdownHandler(SIGNAL_ARGS)
@@ -7667,8 +7684,8 @@ StartupProcessMain(void)
76677684
/*
76687685
* Properly accept or ignore signals the postmaster might send us
76697686
*/
7670-
pqsignal(SIGHUP, SIG_IGN); /* ignore config file updates */
7671-
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
7687+
pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
7688+
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
76727689
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
76737690
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
76747691
pqsignal(SIGALRM, SIG_IGN);

src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 1 deletion
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.575 2009/03/03 10:42:05 heikki Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.576 2009/03/04 13:56:40 heikki Exp $
4141
*
4242
* NOTES
4343
*
@@ -1949,6 +1949,8 @@ SIGHUP_handler(SIGNAL_ARGS)
19491949
(errmsg("received SIGHUP, reloading configuration files")));
19501950
ProcessConfigFile(PGC_SIGHUP);
19511951
SignalChildren(SIGHUP);
1952+
if (StartupPID != 0)
1953+
signal_child(StartupPID, SIGHUP);
19521954
if (BgWriterPID != 0)
19531955
signal_child(BgWriterPID, SIGHUP);
19541956
if (WalWriterPID != 0)

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