Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 109d50d

Browse files
committed
Under new theory of operation wherein postmaster forks children
immediately, we will fork a child even if the database state does not permit connections to be accepted (eg, we are in recovery mode). The child process will correctly reject the connection and exit as soon as it's finished collecting the connection request message. However, this means that reaper() must be prepared to see child process exit signals even while it's waiting for startup or shutdown process to finish. As was, a connection request arriving during a database recovery or shutdown would cause postmaster abort.
1 parent 10e9cd2 commit 109d50d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.229 2001/06/29 16:05:57 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.230 2001/07/01 00:06:23 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -1357,7 +1357,11 @@ pmdie(SIGNAL_ARGS)
13571357
return;
13581358
}
13591359
if (ShutdownPID > 0)
1360+
{
1361+
postmaster_error("Shutdown process %d already running",
1362+
ShutdownPID);
13601363
abort();
1364+
}
13611365

13621366
ShutdownPID = ShutdownDataBase();
13631367
errno = save_errno;
@@ -1409,7 +1413,11 @@ pmdie(SIGNAL_ARGS)
14091413
return;
14101414
}
14111415
if (ShutdownPID > 0)
1416+
{
1417+
postmaster_error("Shutdown process %d already running",
1418+
ShutdownPID);
14121419
abort();
1420+
}
14131421

14141422
ShutdownPID = ShutdownDataBase();
14151423
errno = save_errno;
@@ -1481,35 +1489,33 @@ reaper(SIGNAL_ARGS)
14811489
continue;
14821490
}
14831491

1484-
if (ShutdownPID > 0)
1492+
if (ShutdownPID > 0 && pid == ShutdownPID)
14851493
{
1486-
if (pid != ShutdownPID)
1487-
abort();
14881494
if (exitstatus != 0)
14891495
{
14901496
postmaster_error("Shutdown proc %d exited with status %d", pid, exitstatus);
1491-
fflush(stderr);
14921497
ExitPostmaster(1);
14931498
}
14941499
ExitPostmaster(0);
14951500
}
1496-
if (StartupPID > 0)
1501+
if (StartupPID > 0 && pid == StartupPID)
14971502
{
1498-
if (pid != StartupPID)
1499-
abort();
15001503
if (exitstatus != 0)
15011504
{
15021505
postmaster_error("Startup proc %d exited with status %d - abort",
15031506
pid, exitstatus);
1504-
fflush(stderr);
15051507
ExitPostmaster(1);
15061508
}
15071509
StartupPID = 0;
15081510
FatalError = false; /* done with recovery */
15091511
if (Shutdown > NoShutdown)
15101512
{
15111513
if (ShutdownPID > 0)
1514+
{
1515+
postmaster_error("Shutdown process %d already running",
1516+
ShutdownPID);
15121517
abort();
1518+
}
15131519
ShutdownPID = ShutdownDataBase();
15141520
}
15151521

@@ -1533,7 +1539,6 @@ reaper(SIGNAL_ARGS)
15331539

15341540
if (FatalError)
15351541
{
1536-
15371542
/*
15381543
* Wait for all children exit, then reset shmem and
15391544
* StartupDataBase.

0 commit comments

Comments
 (0)