Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Stop bgworkers during fast shutdown with postmaster in startup phase
authorMichael Paquier <michael@paquier.xyz>
Thu, 30 Aug 2018 00:11:19 +0000 (17:11 -0700)
committerMichael Paquier <michael@paquier.xyz>
Thu, 30 Aug 2018 00:11:19 +0000 (17:11 -0700)
When a postmaster gets into its phase PM_STARTUP, it would start
background workers using BgWorkerStart_PostmasterStart mode immediately,
which would cause problems for a fast shutdown as the postmaster forgets
to send SIGTERM to already-started background workers.  With smart and
immediate shutdowns, this correctly happened, and fast shutdown is the
only mode missing the shot.

Author: Alexander Kukushkin
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/CAFh8B=mvnD8+DZUfzpi50DoaDfZRDfd7S=gwj5vU9GYn8UvHkA@mail.gmail.com
Backpatch-through: 9.5

src/backend/postmaster/postmaster.c

index a8e19c92381dc0de643b1837149ff148026ce175..56d81890bce3b6a9826cabd3827a69e24ded8bbe 100644 (file)
@@ -2734,7 +2734,7 @@ pmdie(SIGNAL_ARGS)
                signal_child(BgWriterPID, SIGTERM);
            if (WalReceiverPID != 0)
                signal_child(WalReceiverPID, SIGTERM);
-           if (pmState == PM_RECOVERY)
+           if (pmState == PM_STARTUP || pmState == PM_RECOVERY)
            {
                SignalSomeChildren(SIGTERM, BACKEND_TYPE_BGWORKER);