Skip to content

Release channel when FixedChannelPool acquire is cancelled (#17287) - #17291

Merged
normanmaurer merged 3 commits into
4.1from
pool_41
Aug 16, 2026
Merged

normanmaurer merged 3 commits into
4.1from
pool_41

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

FixedChannelPool increments acquiredChannelCount before its internal
acquire completes. If the caller cancels the original promise and the
internal acquire succeeds, setSuccess throws and the acquired channel
is neither returned nor closed. The slot remains occupied, pending
acquires may stall, and pool close cannot reach the undelivered channel.

Modification:

Complete the caller promise with trySuccess and release the channel
when the promise was already completed. Add deterministic coverage for
cancellation before delivery, cancelled pending acquires, queue
progression, slot accounting, and pool-close races.

Result:

Cancelled acquires no longer leak a channel or an acquired slot, and
pending acquires continue once the undelivered channel is returned.

Fixes #9669.

Validation:

  • ./mvnw -pl transport -Dtest=FixedChannelPoolTest test
  • ./mvnw -pl transport test (394 tests, 0 failures, 0 errors, 9
    skipped)

Motivation:

`FixedChannelPool` increments `acquiredChannelCount` before its internal
acquire completes. If the caller cancels the original promise and the
internal acquire succeeds, `setSuccess` throws and the acquired channel
is neither returned nor closed. The slot remains occupied, pending
acquires may stall, and pool close cannot reach the undelivered channel.

Modification:

Complete the caller promise with `trySuccess` and release the channel
when the promise was already completed. Add deterministic coverage for
cancellation before delivery, cancelled pending acquires, queue
progression, slot accounting, and pool-close races.

Result:

Cancelled acquires no longer leak a channel or an acquired slot, and
pending acquires continue once the undelivered channel is returned.

Fixes #9669.

Validation:

- `./mvnw -pl transport -Dtest=FixedChannelPoolTest test`
- `./mvnw -pl transport test` (394 tests, 0 failures, 0 errors, 9
skipped)
@testlens-app

testlens-app Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 2d0a63c
▶️ Tests: 358700 executed
⚪️ Checks: 18/18 completed


Learn more about TestLens at testlens.app.

@normanmaurer
normanmaurer merged commit e11f66c into 4.1 Aug 16, 2026
18 of 19 checks passed
@normanmaurer
normanmaurer deleted the pool_41 branch August 16, 2026 09:11
@normanmaurer normanmaurer added this to the 4.1.138.Final milestone Aug 16, 2026
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
…) (netty#17291)

Motivation:

`FixedChannelPool` increments `acquiredChannelCount` before its internal
acquire completes. If the caller cancels the original promise and the
internal acquire succeeds, `setSuccess` throws and the acquired channel
is neither returned nor closed. The slot remains occupied, pending
acquires may stall, and pool close cannot reach the undelivered channel.

Modification:

Complete the caller promise with `trySuccess` and release the channel
when the promise was already completed. Add deterministic coverage for
cancellation before delivery, cancelled pending acquires, queue
progression, slot accounting, and pool-close races.

Result:

Cancelled acquires no longer leak a channel or an acquired slot, and
pending acquires continue once the undelivered channel is returned.

Fixes netty#9669.

Validation:

- `./mvnw -pl transport -Dtest=FixedChannelPoolTest test`
- `./mvnw -pl transport test` (394 tests, 0 failures, 0 errors, 9
skipped)

---------

Co-authored-by: Gimin Kim <[email protected]>
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.

2 participants