forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4518c79
committed
Block signals while allocating DSM memory.
On Linux, we call posix_fallocate() on shm_open()'d memory to avoidlater potential SIGBUS (see commit899bd78).Based on field reports of systems stuck in an EINTR retry loop there,there, we made it possible to break out of that loop via slightly oddcoding where the CHECK_FOR_INTERRUPTS() call was somewhat removed fromthe loop (see commit422952e).On further reflection, that was not a great choice for at least tworeasons:1. If interrupts were held, the CHECK_FOR_INTERRUPTS() would do nothingand the EINTR error would be surfaced to the user.2. If EINTR was reported but neither QueryCancelPending norProcDiePending was set, then we'd dutifully retry, but with a bit moreunderstanding of how posix_fallocate() works, it's now clear that youcan get into a loop that never terminates. posix_fallocate() is not afunction that can do some of the job and tell you about progress if it'sinterrupted, it has to undo what it's done so far and report EINTR, andif signals keep arriving faster than it can complete (cf recoveryconflict signals), you're stuck.Therefore, for now, we'll simply block most signals to guaranteeprogress. SIGQUIT is not blocked (see InitPostmasterChild()), becauseits expected handler doesn't return, and unblockable signals likeSIGCONT are not expected to arrive at a high rate. For good measure,we'll include the ftruncate() call in the blocked region, and add aretry loop.Back-patch to all supported releases.Reported-by: Alvaro Herrera <alvherre@alvh.no-ip.org>Reported-by: Nicola Contu <nicola.contu@gmail.com>Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20220701154105.jjfutmngoedgiad3%40alvherre.pgsql1 parent82785ef commit4518c79
1 file changed
+22
-13
lines changedLines changed: 22 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
| |||
306 | 307 |
| |
307 | 308 |
| |
308 | 309 |
| |
309 |
| - | |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
314 |
| - | |
315 |
| - | |
316 |
| - | |
317 | 310 |
| |
318 | 311 |
| |
319 | 312 |
| |
| |||
361 | 354 |
| |
362 | 355 |
| |
363 | 356 |
| |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
364 | 366 |
| |
365 | 367 |
| |
366 |
| - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
367 | 372 |
| |
368 | 373 |
| |
369 | 374 |
| |
| |||
377 | 382 |
| |
378 | 383 |
| |
379 | 384 |
| |
380 |
| - | |
381 |
| - | |
382 |
| - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
383 | 388 |
| |
384 | 389 |
| |
385 | 390 |
| |
386 | 391 |
| |
387 | 392 |
| |
388 |
| - | |
| 393 | + | |
389 | 394 |
| |
390 | 395 |
| |
391 | 396 |
| |
| |||
397 | 402 |
| |
398 | 403 |
| |
399 | 404 |
| |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
400 | 409 |
| |
401 | 410 |
| |
402 | 411 |
| |
|
0 commit comments
Comments
(0)