- Notifications
You must be signed in to change notification settings - Fork28
Commit803f90a
committed
Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach.
There's a very old race condition in our code to see whether a pre-existingshared memory segment is still in use by a conflicting postmaster: it'spossible for the other postmaster to remove the segment in between ourshmctl() and shmat() calls. It's a narrow window, and there's no riskunless both postmasters are using the same port number, but that's possibleduring parallelized "make check" tests. (Note that while the TAP teststake some pains to choose a randomized port number, pg_regress doesn't.)If it does happen, we treated that as an unexpected case and errored out.To fix, allow EINVAL to be treated as segment-not-present, and the samefor EIDRM on Linux. AFAICS, the considerations here are basicallyidentical to the checks for acceptable shmctl() failures, so I documentedand coded it that way.While at it, adjust PGSharedMemoryAttach's API to remove its undocumenteddependency on UsedShmemSegAddr in favor of passing the attach addressexplicitly. This makes it easier to be sure we're using a null shmaddrwhen probing for segment conflicts (thus avoiding questions about whatEINVAL means). I don't think there was a bug there, but it requiredfragile assumptions about the state of UsedShmemSegAddr duringPGSharedMemoryIsInUse.Commitc098509 may have made this failure more probable by applyingthe conflicting-segment tests more often. Hence, back-patch to allsupported branches, as that was.Discussion:https://postgr.es/m/22224.1557340366@sss.pgh.pa.us1 parente7eed0b commit803f90a
1 file changed
+47
-23
lines changedLines changed: 47 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
| 107 | + | |
107 | 108 |
| |
108 | 109 |
| |
109 | 110 |
| |
| |||
311 | 312 |
| |
312 | 313 |
| |
313 | 314 |
| |
314 |
| - | |
| 315 | + | |
315 | 316 |
| |
316 | 317 |
| |
317 | 318 |
| |
| |||
327 | 328 |
| |
328 | 329 |
| |
329 | 330 |
| |
330 |
| - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
331 | 339 |
| |
332 | 340 |
| |
| 341 | + | |
333 | 342 |
| |
334 | 343 |
| |
335 | 344 |
| |
| |||
339 | 348 |
| |
340 | 349 |
| |
341 | 350 |
| |
342 |
| - | |
343 |
| - | |
| 351 | + | |
344 | 352 |
| |
345 | 353 |
| |
346 | 354 |
| |
| |||
373 | 381 |
| |
374 | 382 |
| |
375 | 383 |
| |
376 |
| - | |
377 |
| - | |
378 |
| - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
379 | 388 |
| |
380 | 389 |
| |
381 | 390 |
| |
382 | 391 |
| |
383 | 392 |
| |
384 | 393 |
| |
385 | 394 |
| |
386 |
| - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
387 | 399 |
| |
388 | 400 |
| |
389 | 401 |
| |
390 | 402 |
| |
391 |
| - | |
392 |
| - | |
393 |
| - | |
394 |
| - | |
395 |
| - | |
396 |
| - | |
397 |
| - | |
| 403 | + | |
398 | 404 |
| |
399 | 405 |
| |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
400 | 418 |
| |
401 |
| - | |
402 |
| - | |
403 |
| - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
404 | 426 |
| |
405 | 427 |
| |
406 | 428 |
| |
| |||
415 | 437 |
| |
416 | 438 |
| |
417 | 439 |
| |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
418 | 445 |
| |
419 | 446 |
| |
420 | 447 |
| |
| |||
633 | 660 |
| |
634 | 661 |
| |
635 | 662 |
| |
636 |
| - | |
637 |
| - | |
638 |
| - | |
639 | 663 |
| |
640 | 664 |
| |
641 | 665 |
| |
| |||
669 | 693 |
| |
670 | 694 |
| |
671 | 695 |
| |
672 |
| - | |
| 696 | + | |
673 | 697 |
| |
674 | 698 |
| |
675 | 699 |
| |
| |||
799 | 823 |
| |
800 | 824 |
| |
801 | 825 |
| |
802 |
| - | |
| 826 | + | |
803 | 827 |
| |
804 | 828 |
| |
805 | 829 |
| |
|
0 commit comments
Comments
(0)