Skip to content

Commit bb892ce

Browse files
committed
Tweak postmaster code to avoid double reporting when bgwriter crashes.
1 parent 5cc3864 commit bb892ce

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 13 additions & 19 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.418 2004/08/01 17:45:43 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.419 2004/08/04 20:09:47 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -248,8 +248,8 @@ static void pmdie(SIGNAL_ARGS);
248248
static void reaper(SIGNAL_ARGS);
249249
static void sigusr1_handler(SIGNAL_ARGS);
250250
static void dummy_handler(SIGNAL_ARGS);
251-
static void CleanupProc(int pid, int exitstatus);
252-
static void HandleChildCrash(int pid, int exitstatus);
251+
static void CleanupBackend(int pid, int exitstatus);
252+
static void HandleChildCrash(int pid, int exitstatus, const char *procname);
253253
static void LogChildExit(int lev, const char *procname,
254254
int pid, int exitstatus);
255255
static int BackendRun(Port *port);
@@ -1947,7 +1947,7 @@ reaper(SIGNAL_ARGS)
19471947
while ((pid = win32_waitpid(&exitstatus)) > 0)
19481948
{
19491949
/*
1950-
* We need to do this here, and not in CleanupProc, since this is
1950+
* We need to do this here, and not in CleanupBackend, since this is
19511951
* to be called on all children when we are done with them. Could
19521952
* move to LogChildExit, but that seems like asking for future
19531953
* trouble...
@@ -2025,9 +2025,8 @@ reaper(SIGNAL_ARGS)
20252025
/*
20262026
* Any unexpected exit of the bgwriter is treated as a crash.
20272027
*/
2028-
LogChildExit(LOG, gettext("background writer process"),
2029-
pid, exitstatus);
2030-
HandleChildCrash(pid, exitstatus);
2028+
HandleChildCrash(pid, exitstatus,
2029+
gettext("background writer process"));
20312030
continue;
20322031
}
20332032

@@ -2067,7 +2066,7 @@ reaper(SIGNAL_ARGS)
20672066
/*
20682067
* Else do standard backend child cleanup.
20692068
*/
2070-
CleanupProc(pid, exitstatus);
2069+
CleanupBackend(pid, exitstatus);
20712070
} /* loop over pending child-death reports */
20722071

20732072
if (FatalError)
@@ -2116,13 +2115,13 @@ reaper(SIGNAL_ARGS)
21162115

21172116

21182117
/*
2119-
* CleanupProc -- cleanup after terminated backend.
2118+
* CleanupBackend -- cleanup after terminated backend.
21202119
*
21212120
* Remove all local state associated with backend.
21222121
*/
21232122
static void
2124-
CleanupProc(int pid,
2125-
int exitstatus) /* child's exit status. */
2123+
CleanupBackend(int pid,
2124+
int exitstatus) /* child's exit status. */
21262125
{
21272126
Dlelem *curr;
21282127

@@ -2136,7 +2135,7 @@ CleanupProc(int pid,
21362135
*/
21372136
if (exitstatus != 0)
21382137
{
2139-
HandleChildCrash(pid, exitstatus);
2138+
HandleChildCrash(pid, exitstatus, gettext("server process"));
21402139
return;
21412140
}
21422141

@@ -2166,8 +2165,7 @@ CleanupProc(int pid,
21662165
* process, and to signal all other remaining children to quickdie.
21672166
*/
21682167
static void
2169-
HandleChildCrash(int pid,
2170-
int exitstatus) /* child's exit status. */
2168+
HandleChildCrash(int pid, int exitstatus, const char *procname)
21712169
{
21722170
Dlelem *curr,
21732171
*next;
@@ -2179,11 +2177,7 @@ HandleChildCrash(int pid,
21792177
*/
21802178
if (!FatalError)
21812179
{
2182-
LogChildExit(LOG,
2183-
(pid == BgWriterPID) ?
2184-
gettext("background writer process") :
2185-
gettext("server process"),
2186-
pid, exitstatus);
2180+
LogChildExit(LOG, procname, pid, exitstatus);
21872181
ereport(LOG,
21882182
(errmsg("terminating any other active server processes")));
21892183
}

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