forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc6d9012
committed
Fix incorrect order of lock file removal and failure to close() sockets.
Commitc9b0cbe accidentally broke theorder of operations during postmaster shutdown: it resulted in removingthe per-socket lockfiles after, not before, postmaster.pid. This createsa race-condition hazard for a new postmaster that's started immediatelyafter observing that postmaster.pid has disappeared; if it sees thesocket lockfile still present, it will quite properly refuse to start.This error appears to be the explanation for at least some of theintermittent buildfarm failures we've seen in the pg_upgrade test.Another problem, which has been there all along, is that the postmasterhas never bothered to close() its listen sockets, but has just allowed themto close at process death. This creates a different race condition for anincoming postmaster: it might be unable to bind to the desired listenaddress because the old postmaster is still incumbent. This might explainsome odd failures we've seen in the past, too. (Note: this is not relatedto the fact that individual backends don't close their client communicationsockets. That behavior is intentional and is not changed by this patch.)Fix by adding an on_proc_exit function that closes the postmaster's portsexplicitly, and (in 9.3 and up) reshuffling the responsibility for whereto unlink the Unix socket files. Lock file unlinking can stay where itis, but teach it to unlink the lock files in reverse order of creation.1 parentbab9599 commitc6d9012
File tree
4 files changed
+75
-30
lines changed- src
- backend
- libpq
- postmaster
- utils/init
- include/libpq
4 files changed
+75
-30
lines changedLines changed: 22 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
247 | 247 |
| |
248 | 248 |
| |
249 | 249 |
| |
250 |
| - | |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
258 |
| - | |
259 |
| - | |
260 |
| - | |
261 |
| - | |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
270 |
| - | |
271 |
| - | |
272 | 250 |
| |
273 | 251 |
| |
274 | 252 |
| |
| |||
550 | 528 |
| |
551 | 529 |
| |
552 | 530 |
| |
553 |
| - | |
| 531 | + | |
554 | 532 |
| |
555 | 533 |
| |
556 |
| - | |
557 |
| - | |
558 |
| - | |
| 534 | + | |
559 | 535 |
| |
560 |
| - | |
561 |
| - | |
562 |
| - | |
563 | 536 |
| |
564 | 537 |
| |
565 | 538 |
| |
| |||
788 | 761 |
| |
789 | 762 |
| |
790 | 763 |
| |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
791 | 784 |
| |
792 | 785 |
| |
793 | 786 |
| |
|
Lines changed: 47 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
370 | 370 |
| |
371 | 371 |
| |
372 | 372 |
| |
| 373 | + | |
373 | 374 |
| |
374 | 375 |
| |
375 | 376 |
| |
| |||
892 | 893 |
| |
893 | 894 |
| |
894 | 895 |
| |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
895 | 901 |
| |
896 | 902 |
| |
897 | 903 |
| |
| |||
916 | 922 |
| |
917 | 923 |
| |
918 | 924 |
| |
| 925 | + | |
| 926 | + | |
| 927 | + | |
919 | 928 |
| |
920 | 929 |
| |
921 | 930 |
| |
922 | 931 |
| |
| 932 | + | |
| 933 | + | |
923 | 934 |
| |
924 | 935 |
| |
925 | 936 |
| |
| |||
1263 | 1274 |
| |
1264 | 1275 |
| |
1265 | 1276 |
| |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1266 | 1313 |
| |
1267 | 1314 |
| |
1268 | 1315 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
884 | 884 |
| |
885 | 885 |
| |
886 | 886 |
| |
887 |
| - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
888 | 892 |
| |
889 | 893 |
| |
890 | 894 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| 53 | + | |
53 | 54 |
| |
54 | 55 |
| |
55 | 56 |
| |
|
0 commit comments
Comments
(0)