pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: oauth: Remove stale events from the kqueue multiplexer
2+ messages / 1 participants
[nested] [flat]

* pgsql: oauth: Remove stale events from the kqueue multiplexer
@ 2025-08-08 16:07 Jacob Champion <jchampion@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Jacob Champion @ 2025-08-08 16:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

oauth: Remove stale events from the kqueue multiplexer

If a socket is added to the kqueue, becomes readable/writable, and
subsequently becomes non-readable/writable again, the kqueue itself will
remain readable until either the socket registration is removed, or the
stale event is cleared via a call to kevent().

In many simple cases, Curl itself will remove the socket registration
quickly, but in real-world usage, this is not guaranteed to happen. The
kqueue can then remain stuck in a permanently readable state until the
request ends, which results in pointless wakeups for the client and
wasted CPU time.

Implement comb_multiplexer() to call kevent() and unstick any stale
events that would cause unnecessary callbacks. This is called right
after drive_request(), before we return control to the client to wait.

Suggested-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CAOYmi+nDZxJHaWj9_jRSyf8uMToCADAmOfJEggsKW-kY7aUwHA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ff5b0824b3b0c58bbb322719628c42b7a4751dd9

Modified Files
--------------
src/interfaces/libpq-oauth/oauth-curl.c | 67 ++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 6 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: oauth: Remove stale events from the kqueue multiplexer
@ 2025-08-08 16:07 Jacob Champion <jchampion@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Jacob Champion @ 2025-08-08 16:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

oauth: Remove stale events from the kqueue multiplexer

If a socket is added to the kqueue, becomes readable/writable, and
subsequently becomes non-readable/writable again, the kqueue itself will
remain readable until either the socket registration is removed, or the
stale event is cleared via a call to kevent().

In many simple cases, Curl itself will remove the socket registration
quickly, but in real-world usage, this is not guaranteed to happen. The
kqueue can then remain stuck in a permanently readable state until the
request ends, which results in pointless wakeups for the client and
wasted CPU time.

Implement comb_multiplexer() to call kevent() and unstick any stale
events that would cause unnecessary callbacks. This is called right
after drive_request(), before we return control to the client to wait.

Suggested-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CAOYmi+nDZxJHaWj9_jRSyf8uMToCADAmOfJEggsKW-kY7aUwHA@mail.gmail.com

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ff181d1f876f32da332238879c3834a3e7825a46

Modified Files
--------------
src/interfaces/libpq-oauth/oauth-curl.c | 67 ++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 6 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-08-08 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-08 16:07 pgsql: oauth: Remove stale events from the kqueue multiplexer Jacob Champion <jchampion@postgresql.org>
2025-08-08 16:07 pgsql: oauth: Remove stale events from the kqueue multiplexer Jacob Champion <jchampion@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox