Re: pgsql: Add kqueue(2) support to the WaitEventSet API.
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Rémi Zara <remi_zara@mac.com>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-02-21T04:30:07Z
Lists: pgsql-hackers
I wrote: > Clearly, we gotta do something about that too. Maybe bumping up > NUM_RESERVED_FDS would be a good idea, but I feel like more-honest > accounting for permanently-eaten FDs would be a better idea. And > in any case we can't suppose that there's a fixed upper limit on > the number of postgres_fdw connections. I'm liking the idea I floated > earlier of letting postgres_fdw forcibly close the oldest LRU entry. A late-night glimmer of an idea: suppose we make fd.c keep count, not just of the open FDs under its control, but also of open FDs not under its control. The latter count would include the initial FDs (stdin/stdout/stderr), and FDs allocated by OpenTransientFile et al, and we could provide functions for other callers to report that they just allocated or released a FD. So postgres_fdw could report, when it opens or closes a PGconn, that the count of external FDs should be increased or decreased. fd.c would then forcibly close VFDs as needed to keep NUM_RESERVED_FDS worth of slop. We still need slop, to provide some daylight for code that isn't aware of this mechanism. But we could certainly get all these known long-lived FDs to be counted, and that would allow fd.c to reduce the number of open VFDs enough to ensure that some slop remains. This idea doesn't fix every possible problem. For instance, if you have a plperlu function that wants to open a bunch of files, I don't see any easy way to ensure we release VFDs to make that possible. But it's sure an improvement on the status quo. regards, tom lane
Commits
-
Don't use EV_CLEAR for kqueue events.
- 9b8aa0929390 13.0 cited
-
Fix kqueue support under debugger on macOS.
- 7bc84a1f304a 13.0 landed
-
Account explicitly for long-lived FDs that are allocated outside fd.c.
- 3d475515a15f 13.0 landed
-
Add kqueue(2) support to the WaitEventSet API.
- 815c2f0972c8 13.0 cited
-
Introduce WaitEventSet API.
- 98a64d0bd713 9.6.0 cited