Skip to content

Claim exact idle generation before closing pooled channels - #2298

Merged
hyperxpro merged 1 commit into
mainfrom
fix/2284-idle-cleaner-generation-race
Aug 2, 2026
Merged

Claim exact idle generation before closing pooled channels#2298
hyperxpro merged 1 commit into
mainfrom
fix/2284-idle-cleaner-generation-race

Conversation

@hyperxpro

Copy link
Copy Markdown
Member

Motivation:

The idle cleaner read a channel's idle timestamp after deciding it had expired, so a lease and re-offer in that window closed a healthy keep-alive on a stale verdict (#2284). Hoisting that read alone leaves a second race: claim and validation stay two steps, so the cleaner can briefly own a generation it never evaluated while a racing poll drops the channel from the pool entirely.

Modification:

IdleState packs ownership, a transfer-in-progress flag and a generation counter into one atomic word, and the cleaner claims with a single CAS against the exact generation its verdict came from.
offer() now transfers ownership rather than stamping unconditionally, and flushPartitions claimsbefore closing so it never closes a channel another caller owns.

Result:
Fixes #2284

Comment thread client/src/test/java/org/asynchttpclient/netty/channel/DefaultChannelPoolTest.java Dismissed
@hyperxpro
hyperxpro merged commit bfc4db0 into main Aug 2, 2026
17 checks passed
@hyperxpro
hyperxpro deleted the fix/2284-idle-cleaner-generation-race branch August 2, 2026 07:00
Sign up for free to 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.

DefaultChannelPool cleaner can close a freshly re-offered channel

1 participant