Re: [PATCH] OAuth: fix performance bug with stuck multiplexer events

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: [PATCH] OAuth: fix performance bug with stuck multiplexer events
Date: 2025-08-06 23:55:44
Message-ID: CAOYmi+mvk8Y7btYJhBzOGiNTY3cCpYZKjhA4-TP2Lkb=zOr4oQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 6, 2025 at 9:13 AM Jacob Champion
<jacob(dot)champion(at)enterprisedb(dot)com> wrote:
> Maybe "drain" would no longer be the
> verb to use there.

I keep describing this as "combing" the queue when I talk about it in
person, so v3-0001 renames this new operation to comb_multiplexer().
And the CI (plus the more strenuous TLS tests) confirms that the
callback count is still stable with this weaker guarantee, so I've
gotten rid of the event-counting code.

Now that I'm no longer counting events, I can collapse the changes to
register_socket(). I can't revert those changes entirely, because then
we regress the case where Curl switches a socket from IN to OUT (this
is enforced by the new unit tests). But I'm not sure that the existing
comment adequately explained that fix anyway, and I didn't remember to
call it out in my initial email, so I've split it out into v3-0002.
It's much smaller.

The tests (now in 0005) have been adjusted for the new "combing"
behavior, and I've added a case to ensure that multiple stale events
are swept up by a single call to comb_multiplexer().

Thanks!
--Jacob

Attachment Content-Type Size
since-v2.diff.txt text/plain 7.0 KB
v3-0001-oauth-Remove-stale-events-from-the-kqueue-multipl.patch application/octet-stream 4.6 KB
v3-0002-oauth-Ensure-unused-socket-registrations-are-remo.patch application/octet-stream 3.0 KB
v3-0003-oauth-Remove-expired-timers-from-the-multiplexer.patch application/octet-stream 5.6 KB
v3-0004-oauth-Track-total-call-count-during-a-client-flow.patch application/octet-stream 4.7 KB
v3-0005-oauth-Add-unit-tests-for-multiplexer-handling.patch application/octet-stream 18.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-08-07 00:06:25 Re: date_trunc invalid units with infinite value
Previous Message Robert Treat 2025-08-06 23:35:08 Re: alter check constraint enforceability