- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitff76983
committed
Improve autoprewarm's handling of early-shutdown scenarios.
Bad things happen if the DBA issues "pg_ctl stop -m fast" beforeautoprewarm finishes loading its list of blocks to prewarm.The current worker process successfully terminates early, but(if this wasn't the last database with blocks to prewarm) theleader process will just try to launch another worker for thenext database. Since the postmaster is now in PM_WAIT_BACKENDSstate, it ignores the launch request, and the leader just sitsuntil it's killed manually.This is mostly the fault of our half-baked design for launchingbackground workers, but a proper fix for that is likely to betoo invasive to be back-patchable. To ameliorate the situation,fix apw_load_buffers() to check whether SIGTERM has arrivedjust before trying to launch another worker. That leaves us withonly a very narrow window in each worker launch where SIGTERMcould occur between the launch request and successful worker start.Another issue is that if the leader process does manage to exit,it unconditionally rewrites autoprewarm.blocks with only theblocks currently in shared buffers, thus forgetting any blocksthat we hadn't reached yet while prewarming. This seems quiteunhelpful, since the next database start will then not have theexpected prewarming benefit. Fix it to not modify the file ifwe shut down before the initial load attempt is complete.Per bug #16785 from John Thompson. Back-patch to v11 wherethe autoprewarm code was introduced.Discussion:https://postgr.es/m/16785-c0207d8c67fb5f25@postgresql.org1 parent08dde1b commitff76983
1 file changed
+25
-5
lines changedLines changed: 25 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
| 156 | + | |
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
| |||
193 | 194 |
| |
194 | 195 |
| |
195 | 196 |
| |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
196 | 201 |
| |
197 | 202 |
| |
198 | 203 |
| |
199 | 204 |
| |
| 205 | + | |
200 | 206 |
| |
201 | 207 |
| |
202 | 208 |
| |
| |||
254 | 260 |
| |
255 | 261 |
| |
256 | 262 |
| |
257 |
| - | |
| 263 | + | |
| 264 | + | |
258 | 265 |
| |
259 | 266 |
| |
260 | 267 |
| |
| |||
387 | 394 |
| |
388 | 395 |
| |
389 | 396 |
| |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
390 | 409 |
| |
391 | 410 |
| |
392 | 411 |
| |
| |||
404 | 423 |
| |
405 | 424 |
| |
406 | 425 |
| |
407 |
| - | |
408 |
| - | |
409 |
| - | |
410 |
| - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
411 | 431 |
| |
412 | 432 |
| |
413 | 433 |
| |
|
0 commit comments
Comments
(0)