Skip to content

No blocking acquire on event loop - #2252

Merged
hyperxpro merged 1 commit into
mainfrom
no-blocking-acquire-on-event-loop
Jul 18, 2026
Merged

No blocking acquire on event loop#2252
hyperxpro merged 1 commit into
mainfrom
no-blocking-acquire-on-event-loop

Conversation

@hyperxpro

@hyperxprohyperxpro commented Jul 18, 2026

Copy link
Copy Markdown
Member

Motivation:

#2226 made the connection-permit acquire non-blocking on the event loop. CombinedConnectionSemaphore's non-blocking path takes the global permit first and then the per-host permit, releasing the global one if the per-host permit is unavailable. That releaseGlobal branch is the single place the non-blocking path can leak the global permit, yet it had no coverage: the existing combinedNonBlockingFailsFastWhenExhausted uses equal global and per-host limits (1, 1), so the acquire is rejected at the global gate and never reaches the per-host rejection where releaseGlobal runs.

Modification:

Add combinedNonBlockingReleasesGlobalPermitWhenPerHostExhausted using a wider global limit (2) than per-host (1). The non-blocking acquire passes the global gate, is rejected by the per-host limit (asserted as TooManyConnectionsPerHostException), and a follow-up non-blocking acquire for a different host must succeed; proving the global permit taken during the failed attempt was released rather than leaked.

Result:

The global-permit release path of the non-blocking combined acquire is now covered; a regression that leaked the global permit on per-host rejection would starve other hosts of the global permit and fail this test.

Motivation:
#2226 made the connection-permit acquire non-blocking on the event loop.
CombinedConnectionSemaphore's non-blocking path takes the global permit first
and then the per-host permit, releasing the global one if the per-host permit is
unavailable. That releaseGlobal branch is the single place the non-blocking path
can leak the global permit, yet it had no coverage: the existing
combinedNonBlockingFailsFastWhenExhausted uses equal global and per-host limits
(1, 1), so the acquire is rejected at the global gate and never reaches the
per-host rejection where releaseGlobal runs.
Modification:
Add combinedNonBlockingReleasesGlobalPermitWhenPerHostExhausted using a wider
global limit (2) than per-host (1). The non-blocking acquire passes the global
gate, is rejected by the per-host limit (asserted as
TooManyConnectionsPerHostException), and a follow-up non-blocking acquire for a
different host must succeed; proving the global permit taken during the failed
attempt was released rather than leaked.
Result:
The global-permit release path of the non-blocking combined acquire is now
covered; a regression that leaked the global permit on per-host rejection would
starve other hosts of the global permit and fail this test.
@hyperxpro
hyperxproforce-pushed the no-blocking-acquire-on-event-loop branch from 580626f to 6e89a8dCompareJuly 18, 2026 20:03
@hyperxpro
hyperxpro merged commit 90ea6d7 into mainJul 18, 2026
17 checks passed
@hyperxpro
hyperxpro deleted the no-blocking-acquire-on-event-loop branch July 18, 2026 20:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@hyperxpro