Skip to content

Commit c528c42

Browse files
committed
More startup/shutdown log messages.
1 parent b1ec184 commit c528c42

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.122 1999/10/06 22:44:25 vadim Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.123 1999/10/08 02:16:22 vadim Exp $
1414
*
1515
* NOTES
1616
*
@@ -169,10 +169,12 @@ static int MaxBackends = DEF_MAXBACKENDS;
169169
* semaphores, even if you never actually use that many backends.
170170
*/
171171

172-
static int NextBackendTag = MAXINT; /* XXX why count down not up? */
173-
static char *progname = (char *) NULL;
174-
static char **real_argv;
175-
static int real_argc;
172+
static int NextBackendTag = MAXINT; /* XXX why count down not up? */
173+
static char *progname = (char *) NULL;
174+
static char **real_argv;
175+
static int real_argc;
176+
177+
static time_t tnow;
176178

177179
/*
178180
* Default Values
@@ -1208,6 +1210,9 @@ pmdie(SIGNAL_ARGS)
12081210
if (Shutdown >= SmartShutdown)
12091211
return;
12101212
Shutdown = SmartShutdown;
1213+
tnow = time(NULL);
1214+
fprintf(stderr, "Smart Shutdown request at %s", ctime(&tnow));
1215+
fflush(stderr);
12111216
if (DLGetHead(BackendList)) /* let reaper() handle this */
12121217
return;
12131218
/*
@@ -1230,11 +1235,18 @@ pmdie(SIGNAL_ARGS)
12301235
*/
12311236
if (Shutdown >= FastShutdown)
12321237
return;
1238+
tnow = time(NULL);
1239+
fprintf(stderr, "Fast Shutdown request at %s", ctime(&tnow));
1240+
fflush(stderr);
12331241
if (DLGetHead(BackendList)) /* let reaper() handle this */
12341242
{
12351243
Shutdown = FastShutdown;
12361244
if (!FatalError)
1245+
{
1246+
fprintf(stderr, "Aborting any active transaction...\n");
1247+
fflush(stderr);
12371248
SignalChildren(SIGTERM);
1249+
}
12381250
return;
12391251
}
12401252
if (Shutdown > NoShutdown)
@@ -1261,6 +1273,9 @@ pmdie(SIGNAL_ARGS)
12611273
* abort all children with SIGUSR1 and exit without
12621274
* attempt to properly shutdown data base system.
12631275
*/
1276+
tnow = time(NULL);
1277+
fprintf(stderr, "Immediate Shutdown request at %s", ctime(&tnow));
1278+
fflush(stderr);
12641279
if (ShutdownPID > 0)
12651280
kill(ShutdownPID, SIGQUIT);
12661281
else if (StartupPID > 0)
@@ -1308,15 +1323,23 @@ reaper(SIGNAL_ARGS)
13081323
if (pid != ShutdownPID)
13091324
abort();
13101325
if (exitstatus != 0)
1311-
abort();
1326+
{
1327+
fprintf(stderr, "Shutdown failed - abort\n");
1328+
fflush(stderr);
1329+
proc_exit(1);
1330+
}
13121331
proc_exit(0);
13131332
}
13141333
if (StartupPID > 0)
13151334
{
13161335
if (pid != StartupPID)
13171336
abort();
13181337
if (exitstatus != 0)
1319-
abort();
1338+
{
1339+
fprintf(stderr, "Startup failed - abort\n");
1340+
fflush(stderr);
1341+
proc_exit(1);
1342+
}
13201343
StartupPID = 0;
13211344
FatalError = false;
13221345
if (Shutdown > NoShutdown)
@@ -1341,9 +1364,11 @@ reaper(SIGNAL_ARGS)
13411364
return;
13421365
if (StartupPID > 0 || ShutdownPID > 0)
13431366
return;
1344-
if (DebugLvl)
1345-
fprintf(stderr, "%s: CleanupProc: reinitializing shared memory and semaphores\n",
1346-
progname);
1367+
tnow = time(NULL);
1368+
fprintf(stderr, "Server processes were terminated at %s"
1369+
"Reinitializing shared memory and semaphores\n",
1370+
ctime(&tnow));
1371+
fflush(stderr);
13471372
shmem_exit(0);
13481373
reset_shared(PostPortName);
13491374
StartupPID = StartupDataBase();
@@ -1410,6 +1435,14 @@ CleanupProc(int pid,
14101435
return;
14111436
}
14121437

1438+
if (!FatalError)
1439+
{
1440+
tnow = time(NULL);
1441+
fprintf(stderr, "Server process (pid %d) exited with status %d at %s"
1442+
"Terminating any active server processes...\n",
1443+
pid, exitstatus, ctime(&tnow));
1444+
fflush(stderr);
1445+
}
14131446
FatalError = true;
14141447
curr = DLGetHead(BackendList);
14151448
while (curr)

0 commit comments

Comments
 (0)