Fix assertion failure by an immediate shutdown.
In PM_WAIT_DEAD_END state, checkpointer process must be dead already.
But an immediate shutdown could make postmaster's state machine
transition to PM_WAIT_DEAD_END state even if checkpointer process is
still running, and which caused assertion failure. This bug was introduced
in commit 457d6cf049
.
This patch ensures that postmaster's state machine doesn't transition to
PM_WAIT_DEAD_END state in an immediate shutdown while checkpointer
process is running.
This commit is contained in:
parent
f347f26807
commit
91c3613d37
|
@ -3328,19 +3328,21 @@ PostmasterStateMachine(void)
|
||||||
* PM_WAIT_BACKENDS state ends when we have no regular backends
|
* PM_WAIT_BACKENDS state ends when we have no regular backends
|
||||||
* (including autovac workers), no bgworkers (including unconnected
|
* (including autovac workers), no bgworkers (including unconnected
|
||||||
* ones), and no walwriter, autovac launcher or bgwriter. If we are
|
* ones), and no walwriter, autovac launcher or bgwriter. If we are
|
||||||
* doing crash recovery then we expect the checkpointer to exit as
|
* doing crash recovery or an immediate shutdown then we expect
|
||||||
* well, otherwise not. The archiver, stats, and syslogger processes
|
* the checkpointer to exit as well, otherwise not. The archiver,
|
||||||
* are disregarded since they are not connected to shared memory; we
|
* stats, and syslogger processes are disregarded since
|
||||||
* also disregard dead_end children here. Walsenders are also
|
* they are not connected to shared memory; we also disregard
|
||||||
* disregarded, they will be terminated later after writing the
|
* dead_end children here. Walsenders are also disregarded,
|
||||||
* checkpoint record, like the archiver process.
|
* they will be terminated later after writing the checkpoint record,
|
||||||
|
* like the archiver process.
|
||||||
*/
|
*/
|
||||||
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_WORKER) == 0 &&
|
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_WORKER) == 0 &&
|
||||||
CountUnconnectedWorkers() == 0 &&
|
CountUnconnectedWorkers() == 0 &&
|
||||||
StartupPID == 0 &&
|
StartupPID == 0 &&
|
||||||
WalReceiverPID == 0 &&
|
WalReceiverPID == 0 &&
|
||||||
BgWriterPID == 0 &&
|
BgWriterPID == 0 &&
|
||||||
(CheckpointerPID == 0 || !FatalError) &&
|
(CheckpointerPID == 0 ||
|
||||||
|
(!FatalError && Shutdown < ImmediateShutdown)) &&
|
||||||
WalWriterPID == 0 &&
|
WalWriterPID == 0 &&
|
||||||
AutoVacPID == 0)
|
AutoVacPID == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue