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

Commit 91c3613

Browse files
committed
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 457d6cf. 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.
1 parent f347f26 commit 91c3613

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/backend/postmaster/postmaster.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -3328,19 +3328,21 @@ PostmasterStateMachine(void)
33283328
* PM_WAIT_BACKENDS state ends when we have no regular backends
33293329
* (including autovac workers), no bgworkers (including unconnected
33303330
* ones), and no walwriter, autovac launcher or bgwriter. If we are
3331-
* doing crash recovery then we expect the checkpointer to exit as
3332-
* well, otherwise not. The archiver, stats, and syslogger processes
3333-
* are disregarded since they are not connected to shared memory; we
3334-
* also disregard dead_end children here. Walsenders are also
3335-
* disregarded, they will be terminated later after writing the
3336-
* checkpoint record, like the archiver process.
3331+
* doing crash recovery or an immediate shutdown then we expect
3332+
* the checkpointer to exit as well, otherwise not. The archiver,
3333+
* stats, and syslogger processes are disregarded since
3334+
* they are not connected to shared memory; we also disregard
3335+
* dead_end children here. Walsenders are also disregarded,
3336+
* they will be terminated later after writing the checkpoint record,
3337+
* like the archiver process.
33373338
*/
33383339
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_WORKER) == 0 &&
33393340
CountUnconnectedWorkers() == 0 &&
33403341
StartupPID == 0 &&
33413342
WalReceiverPID == 0 &&
33423343
BgWriterPID == 0 &&
3343-
(CheckpointerPID == 0 || !FatalError) &&
3344+
(CheckpointerPID == 0 ||
3345+
(!FatalError && Shutdown < ImmediateShutdown)) &&
33443346
WalWriterPID == 0 &&
33453347
AutoVacPID == 0)
33463348
{

0 commit comments

Comments
 (0)