Re: Unportable implementation of background worker start
Tom Lane <tgl@sss.pgh.pa.us>
Attachments
- allow-postmaster-to-have-a-self-pipe.patch (text/x-diff) patch
I wrote: > Alvaro Herrera <alvherre@2ndquadrant.com> writes: >> Tom Lane wrote: >>> Hm. Do you have a more-portable alternative? >> I was thinking in a WaitEventSet from latch.c. > My first reaction was that that sounded like a lot more work than removing > two lines from maybe_start_bgworker and adjusting some comments. But on > closer inspection, the slow-bgworker-start issue isn't the only problem > here. On a machine that restarts select()'s timeout after an interrupt, > as (at least) HPUX does, the postmaster will actually never iterate > ServerLoop's loop except immediately after receiving a new connection > request. I had a go at making the postmaster use a WaitEventSet, and immediately ran into problems: latch.c is completely unprepared to be used anywhere except a postmaster child process. I think we can get around the issue for the self-pipe, as per the attached untested patch. But there remains a problem: we should do a FreeWaitEventSet() after forking a child process to ensure that postmaster children aren't running around with open FDs for the postmaster's stuff. This is no big problem in a regular Unix build; we can give ClosePostmasterPorts() the responsibility. It *is* a problem in EXEC_BACKEND children, which won't have inherited the WaitEventSet data structure. Maybe we could ignore the problem for Unix EXEC_BACKEND builds, since we consider those to be for debug purposes only, not for production. But I don't think we can get away with it for Windows --- or are the HANDLEs in a Windows WaitEventSet not inheritable resources? 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