Re: Using WaitEventSet in the postmaster
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-05T09:45:57Z
Lists: pgsql-hackers
Attachments
- v3-0001-Give-the-postmaster-a-WaitEventSet-and-a-latch.patch (text/x-patch) patch v3-0001
On Sat, Dec 3, 2022 at 10:41 AM Thomas Munro <thomas.munro@gmail.com> wrote: > Here's an iteration like that. Still WIP grade. It passes, but there > must be something I don't understand about this computer program yet, > because if I move the "if (pending_..." section up into the block > where WL_LATCH_SET has arrived (instead of testing those variables > every time through the loop), a couple of tests leave zombie > (unreaped) processes behind, indicating that something funky happened > to the state machine that I haven't yet grokked. Will look more next > week. Duh. The reason for that was the pre-existing special case for PM_WAIT_DEAD_END, which used a sleep(100ms) loop to wait for children to exit, which I needed to change to a latch wait. Fixed in the next iteration, attached. The reason for the existing sleep-based approach was that we didn't want to accept any more connections (or spin furiously because the listen queue was non-empty). So in this version I invented a way to suppress socket events temporarily with WL_SOCKET_IGNORE, and then reactivate them after crash reinit. Still WIP, but I hope travelling in the right direction.
Commits
-
Remove unneeded volatile qualifiers from postmaster.c.
- 8d2c1913ed3d 16.0 landed
-
Fix WaitEventSetWait() buffer overrun.
- f1821b58fc8d 16.0 landed
- 8a98523a542f 15.2 landed
- 547e60b8317e 14.7 landed
- c159b0383fa6 13.10 landed
- bf388ab82850 12.14 landed
- 1b40710a8c89 11.19 landed
-
Refactor DetermineSleepTime() to use milliseconds.
- 5a26c7b310b6 16.0 landed
-
Use WaitEventSet API for postmaster's event loop.
- 7389aad63666 16.0 landed
-
Allow parent's WaitEventSets to be freed after fork().
- b5d0f8ec01c0 16.0 landed
-
Don't leak a signalfd when using latches in the postmaster.
- 1f0019de2fe3 16.0 landed
-
Add WL_SOCKET_ACCEPT event to WaitEventSet API.
- 30829e52ff1a 16.0 landed
-
From: Phil Thompson <phil@river-bank.demon.co.uk>
- d5bbe2aca55b 7.1.1 cited