- Notifications
You must be signed in to change notification settings - Fork5
Commitaa1351f
committed
Allow multiple bgworkers to be launched per postmaster iteration.
Previously, maybe_start_bgworker() would launch at most one bgworkerprocess per call, on the grounds that the postmaster might otherwiseneglect its other duties for too long. However, that seems overlyconservative, especially since bad effects only become obvious whenmany hundreds of bgworkers need to be launched at once. On the otherside of the coin is that the existing logic could result in substantialdelay of bgworker launches, because ServerLoop isn't guaranteed toiterate immediately after a signal arrives. (My attempt to fix thatby using pselect(2) encountered too many portability question marks,and in any case could not help on platforms without pselect().)One could also question the wisdom of using an O(N^2) processingmethod if the system is intended to support so many bgworkers.As a compromise, allow that function to launch up to 100 bgworkersper call (and in consequence, rename it to maybe_start_bgworkers).This will allow any normal parallel-query request for workersto be satisfied immediately during sigusr1_handler, avoiding thequestion of whether ServerLoop will be able to launch more promptly.There is talk of rewriting the postmaster to use a WaitEventSet toavoid the signal-response-delay problem, but I'd argue that this changeshould be kept even after that happens (if it ever does).Backpatch to 9.6 where parallel query was added. The issue existsbefore that, but previous uses of bgworkers typically aren't assensitive to how quickly they get launched.Discussion:https://postgr.es/m/4707.1493221358@sss.pgh.pa.us1 parentfda4fec commitaa1351f
1 file changed
+22
-17
lines changedLines changed: 22 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
421 | 421 |
| |
422 | 422 |
| |
423 | 423 |
| |
424 |
| - | |
| 424 | + | |
425 | 425 |
| |
426 | 426 |
| |
427 | 427 |
| |
| |||
1346 | 1346 |
| |
1347 | 1347 |
| |
1348 | 1348 |
| |
1349 |
| - | |
| 1349 | + | |
1350 | 1350 |
| |
1351 | 1351 |
| |
1352 | 1352 |
| |
| |||
1813 | 1813 |
| |
1814 | 1814 |
| |
1815 | 1815 |
| |
1816 |
| - | |
| 1816 | + | |
1817 | 1817 |
| |
1818 | 1818 |
| |
1819 | 1819 |
| |
| |||
2859 | 2859 |
| |
2860 | 2860 |
| |
2861 | 2861 |
| |
2862 |
| - | |
| 2862 | + | |
2863 | 2863 |
| |
2864 | 2864 |
| |
2865 | 2865 |
| |
| |||
5026 | 5026 |
| |
5027 | 5027 |
| |
5028 | 5028 |
| |
5029 |
| - | |
| 5029 | + | |
5030 | 5030 |
| |
5031 | 5031 |
| |
5032 | 5032 |
| |
| |||
5726 | 5726 |
| |
5727 | 5727 |
| |
5728 | 5728 |
| |
5729 |
| - | |
| 5729 | + | |
5730 | 5730 |
| |
5731 |
| - | |
5732 |
| - | |
5733 |
| - | |
| 5731 | + | |
| 5732 | + | |
5734 | 5733 |
| |
5735 |
| - | |
| 5734 | + | |
5736 | 5735 |
| |
5737 | 5736 |
| |
5738 | 5737 |
| |
5739 | 5738 |
| |
5740 | 5739 |
| |
5741 |
| - | |
| 5740 | + | |
5742 | 5741 |
| |
5743 |
| - | |
| 5742 | + | |
| 5743 | + | |
5744 | 5744 |
| |
| 5745 | + | |
5745 | 5746 |
| |
5746 | 5747 |
| |
5747 | 5748 |
| |
| |||
5826 | 5827 |
| |
5827 | 5828 |
| |
5828 | 5829 |
| |
5829 |
| - | |
5830 |
| - | |
5831 |
| - | |
| 5830 | + | |
| 5831 | + | |
| 5832 | + | |
| 5833 | + | |
5832 | 5834 |
| |
5833 |
| - | |
5834 |
| - | |
| 5835 | + | |
| 5836 | + | |
| 5837 | + | |
| 5838 | + | |
| 5839 | + | |
5835 | 5840 |
| |
5836 | 5841 |
| |
5837 | 5842 |
| |
|
0 commit comments
Comments
(0)