Fix latch event policy that hid socket events.
authorThomas Munro <tmunro@postgresql.org>
Mon, 20 Jan 2025 02:17:47 +0000 (15:17 +1300)
committerThomas Munro <tmunro@postgresql.org>
Mon, 20 Jan 2025 03:55:11 +0000 (16:55 +1300)
commitb4b52c911aafe482f008142d751b9ede6f85f52e
tree35396f4c8e9747afb45f4c6f594c997ad0264351
parent2c2e1d4f42c00784b46023ba123bd5cd38d914fb
Fix latch event policy that hid socket events.

If a WaitEventSetWait() caller asks for multiple events, an already set
latch would previously prevent other events from being reported at the
same time.  Now, we'll also poll the kernel for other events that would
fit in the caller's output buffer with a zero wait time.  This policy
change doesn't affect callers that ask for only one event.

The main caller affected is the postmaster.  If its latch is set
extremely frequently by backends launching workers and workers exiting,
we don't want it to handle only those jobs and ignore incoming client
connections.

Back-patch to 16 where the postmaster began using the API.  The
fast-return policy changed here is older than that, but doesn't cause
any known problems in earlier releases.

Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/Z1n5UpAiGDmFcMmd%40nathan
src/backend/storage/ipc/latch.c