forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1c6066f
committed
Fix postmaster's behavior during smart shutdown.
Up to now, upon receipt of a SIGTERM ("smart shutdown" command), thepostmaster has immediately killed all "optional" background processes,and subsequently refused to launch new ones while it's waiting forforeground client processes to exit. No doubt this seemed like an OKpolicy at some point; but it's a pretty bad one now, because it makesfor a seriously degraded environment for the remaining clients:* Parallel queries are killed, and new ones fail to launch. (And ourparallel-query infrastructure utterly fails to deal with the casein a reasonable way --- it just hangs waiting for workers that arenot going to arrive. There is more work needed in that area IMO.)* Autovacuum ceases to function. We can tolerate that for awhile,but if bulk-update queries continue to run in the surviving clientsessions, there's eventually going to be a mess. In the worst casethe system could reach a forced shutdown to prevent XID wraparound.* The bgwriter and walwriter are also stopped immediately, likelyresulting in performance degradation.Hence, let's rearrange things so that the only immediate change inbehavior is refusing to let in new normal connections. Once the lastnormal connection is gone, shut everything down as though we'd receiveda "fast" shutdown. To implement this, remove the PM_WAIT_BACKUP andPM_WAIT_READONLY states, instead staying in PM_RUN or PM_HOT_STANDBYwhile normal connections remain. A subsidiary state variable trackswhether or not we're letting in new connections in those states.This also allows having just one copy of the logic for killing childprocesses in smart and fast shutdown modes. I moved that logic intoPostmasterStateMachine() by inventing a new state PM_STOP_BACKENDS.Back-patch to 9.6 where parallel query was added. In principlethis'd be a good idea in 9.5 as well, but the risk/reward ratiois not as good there, since lack of autovacuum is not a problemduring typical uses of smart shutdown.Per report from Bharath Rupireddy.Patch by me, reviewed by Thomas MunroDiscussion:https://postgr.es/m/CALj2ACXAZ5vKxT9P7P89D87i3MDO9bfS+_bjMHgnWJs8uwUOOw@mail.gmail.com1 parentcabec1d commit1c6066f
File tree
4 files changed
+126
-121
lines changed- doc/src/sgml/ref
- src
- backend
- postmaster
- utils/init
- include/libpq
4 files changed
+126
-121
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
185 | 185 |
| |
186 | 186 |
| |
187 | 187 |
| |
188 |
| - | |
189 |
| - | |
| 188 | + | |
| 189 | + | |
190 | 190 |
| |
191 | 191 |
| |
192 | 192 |
| |
|
0 commit comments
Comments
(0)