Re: Unportable implementation of background worker start
Tom Lane <tgl@sss.pgh.pa.us>
Alvaro Herrera <alvherre@2ndquadrant.com> writes: > Tom Lane wrote: >> I'm coming back to the idea that at least in the back branches, the >> thing to do is allow maybe_start_bgworker to start multiple workers. >> >> Is there any actual evidence for the claim that that might have >> bad side effects? > Well, I ran tests with a few dozen thousand sample workers and the > neglect for other things (such as connection requests) was visible, but > that's probably not a scenario many servers run often currently. Indeed. I'm pretty skeptical that that's an interesting case, and if it is, the current coding is broken anyway, because with that many workers you are going to start noticing that running maybe_start_bgworker over again for each worker is an O(N^2) proposition. Admittedly, iterating the loop in maybe_start_bgworker is really cheap compared to a fork(), but eventually the big-O problem is going to eat your lunch. > I don't strongly object to the idea of removing the "return" in older > branches, since it's evidently a problem. However, as bgworkers start > to be used more, I think we should definitely have some protection. In > a system with a large number of workers available for parallel queries, > it seems possible for a high velocity server to get stuck in the loop > for some time. (I haven't actually verified this, though. My > experiments were with the early kind, static bgworkers.) It might be sensible to limit the number of workers launched per call, but I think the limit should be quite a bit higher than 1 ... something like 100 or 1000 might be appropriate. regards, tom lane
Commits
-
Cope with glibc too old to have epoll_create1().
- 53b157846024 9.6.3 landed
- 82ebbeb0abfe 10.0 landed
-
Make latch.c more paranoid about child-process cases.
- fa31b6f4e969 10.0 landed
- 866452cd8b52 9.6.3 landed
-
Allow multiple bgworkers to be launched per postmaster iteration.
- aa1351f1eec4 10.0 landed
- e880df25ec35 9.6.3 landed
-
Revert "Use pselect(2) not select(2), if available, to wait in postmaster's loop."
- e615605239f6 9.6.3 landed
- 64925603c972 10.0 landed
-
Use pselect(2) not select(2), if available, to wait in postmaster's loop.
- b9515b628797 9.6.3 landed
- 81069a9efc5a 10.0 landed
-
Run the postmaster's signal handlers without SA_RESTART.
- 8939020853e6 10.0 landed
- dfa4baf91cee 9.6.3 landed
-
Fix postmaster's handling of fork failure for a bgworker process.
- dba1f310a564 9.5.7 landed
- 63f64d2824b2 9.6.3 landed
- 4fe04244b584 10.0 landed
- 436b560b86ca 9.4.12 landed
-
Partially revert commit 536d47bd9d5fce8d91929bee3128fa1d08dbcc57.
- 5041cdf2b792 10.0 landed
-
Avoid depending on non-POSIX behavior of fcntl(2).
- 3e51725b3854 10.0 landed
- f07f6b62c9a7 9.6.3 landed
- ce521e50eb56 9.4.12 landed
- ad8fb69cccf4 9.2.21 landed
- 9f8be7542156 9.5.7 landed
- 899960b9fec2 9.3.17 landed
-
Remove long-obsolete catering for platforms without F_SETFD/FD_CLOEXEC.
- 536d47bd9d5f 10.0 landed