GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — POOL: Release Channel when SimpleChannelPool acquire is cancelled by renechoi · Pull Request #17569 · netty/netty

Conversation

@renechoi

@renechoi renechoi commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

notifyConnect() completes the acquire Promise with trySuccess(...) and releases the Channel if already completed. notifyHealthCheck(), the reuse path, still uses setSuccess(...).

doHealthCheck runs via loop.execute(...) when acquire() is called off its event loop, so a cancel can land while that task is queued, even with the stock ACTIVE checker. setSuccess(...) then throws into closeAndFail(...): a healthy pooled Channel is closed and its channelAcquired(...) gets no channelReleased(...).

#17287 gave FixedChannelPool this guard.

Modification

notifyHealthCheck() mirrors notifyConnect(), plus a regression test on a hand-completed health check.

Result

Reverting just the source hunk fails that test on releasedCount(), 2 expected, 1 seen. With it, 34/34.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@renechoi
POOL: Release the Channel when an acquire is cancelled
f82323a
Motivation:

SimpleChannelPool hands an acquired Channel to the caller's Promise in two
places. notifyConnect() completes the Promise with trySuccess(...) and releases
the Channel back into the pool when the Promise turns out to be completed
already, which is what happens when the caller cancelled the acquire.
notifyHealthCheck(), the path taken when an already pooled Channel is reused,
still completes the Promise with setSuccess(...).

So when the acquire Promise is completed while the health check of a pooled
Channel is still pending, setSuccess(...) throws IllegalStateException. The
surrounding catch routes it to closeAndFail(...), which closes a healthy pooled
Channel instead of offering it back. handler.channelAcquired(...) has already
been invoked at that point, so the matching channelReleased(...) callback never
arrives and a ChannelPoolHandler that tracks acquire and release counts stays
out of balance for the rest of the pool's lifetime.

FixedChannelPool.AcquireListener already guards the same race the same way.

Modifications:

- Complete the acquire Promise in notifyHealthCheck() with trySuccess(...) and
  release the Channel again when it was completed already, mirroring what
  notifyConnect() does.
- Add a regression test that cancels the acquire Promise while the health check
  of a pooled Channel is pending, and asserts that the Channel stays active, is
  handed back by the next acquire, and that the pool handler callbacks stay
  balanced.

Result:

Cancelling an acquire no longer destroys a pooled Channel, and the
channelAcquired and channelReleased callbacks stay balanced.
@testlens-app

testlens-app Bot commented Sep 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / macos-x86_64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueJdkLoopbackSocketSslEchoTest > testSslEcho(SslContext, SslContext, Renegotiation, boolean, boolean, boolean, boolean, boolean, TestInfo) > 49: serverEngine = io.netty.handler.ssl.JdkSslServerContext@1c98b4eb, clientEngine = io.netty.handler.ssl.JdkSslClientContext@45801322, renegotiation = CLIENT_INITIATED(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA), serverUsesDelegatedTaskExecutor = true, clientUsesDelegatedTaskExecutor = false, autoRead = false, useChunkedWriteHandler = false, useCompositeByteBuf = false ❌ 1% 🟡

🏷️ Commit: f82323a
▶️ Tests: 435059 executed
🟡 Checks: 29/32 completed

Test Failures

KQueueJdkLoopbackSocketSslEchoTest > testSslEcho(SslContext, SslContext, Renegotiation, boolean, boolean, boolean, boolean, boolean, TestInfo) > 49: serverEngine = io.netty.handler.ssl.JdkSslServerContext@1c98b4eb, clientEngine = io.netty.handler.ssl.JdkSslClientContext@45801322, renegotiation = CLIENT_INITIATED(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA), serverUsesDelegatedTaskExecutor = true, clientUsesDelegatedTaskExecutor = false, autoRead = false, useChunkedWriteHandler = false, useCompositeByteBuf = false (Netty/Transport/Native/KQueue in Build PR / macos-x86_64-java11-boringssl build)
java.util.concurrent.TimeoutException: testSslEcho(io.netty.handler.ssl.SslContext, io.netty.handler.ssl.SslContext, io.netty.testsuite.transport.socket.SocketSslEchoTest$Renegotiation, boolean, boolean, boolean, boolean, boolean, org.junit.jupiter.api.TestInfo) timed out after 30000 milliseconds
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	Suppressed: java.lang.InterruptedException
		at java.base/java.lang.Object.wait(Native Method)
		at java.base/java.lang.Object.wait(Object.java:328)
		at io.netty.util.concurrent.DefaultPromise.await(DefaultPromise.java:268)
		at io.netty.util.concurrent.DefaultPromise.sync(DefaultPromise.java:419)
		at io.netty.util.concurrent.DefaultPromise.sync(DefaultPromise.java:37)
		at io.netty.testsuite.transport.socket.SocketSslEchoTest.testSslEcho(SocketSslEchoTest.java:326)
		at io.netty.testsuite.transport.socket.SocketSslEchoTest$1.run(SocketSslEchoTest.java:256)
		at io.netty.testsuite.transport.socket.SocketSslEchoTest$1.run(SocketSslEchoTest.java:253)
		at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
		at io.netty.testsuite.transport.socket.SocketSslEchoTest.testSslEcho(SocketSslEchoTest.java:253)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		... 40 more

Rerun Controls

Note

Checks are currently running using the configuration below.

Select tests to mute in this pull request:

🔲 KQueueJdkLoopbackSocketSslEchoTest > testSslEcho(SslContext, SslContext, Renegotiation, boolean, boolean, boolean, boolean, boolean, TestInfo)

Reuse successful test results:

🔲 ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

🔲 Rerun jobs


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.19.Final milestone Sep 21, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Sep 21, 2026
@normanmaurer
normanmaurer merged commit 6b257ce into netty:4.2 Sep 21, 2026
29 of 30 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17578

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Sep 21, 2026
Auto-port 4.1: POOL: Release Channel when SimpleChannelPool acquire is cancelled #17578
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Sep 21, 2026
@netty-project-bot

netty-project-bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Sep 21, 2026

Copy link
Copy Markdown
Member

Port for 5.0: #17580

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer added a commit that referenced this pull request Sep 21, 2026
@normanmaurer @renechoi
Port: POOL: Release Channel when SimpleChannelPool acquire is cancell…
f973c98
…ed (#17569) (#17580)

`notifyConnect()` completes the acquire `Promise` with `trySuccess(...)`
and releases the `Channel` if already completed. `notifyHealthCheck()`,
the reuse path, still uses `setSuccess(...)`.

`doHealthCheck` runs via `loop.execute(...)` when `acquire()` is called
off its event loop, so a cancel can land while that task is queued, even
with the stock `ACTIVE` checker. `setSuccess(...)` then throws into
`closeAndFail(...)`: a healthy pooled `Channel` is closed and its
`channelAcquired(...)` gets no `channelReleased(...)`.

`notifyHealthCheck()` mirrors `notifyConnect()`, plus a regression test
on a hand-completed health check.

Reverting just the source hunk fails that test on `releasedCount()`, 2
expected, 1 seen. With it, 34/34.

Co-authored-by: renechoi <[email protected]>
normanmaurer pushed a commit that referenced this pull request Sep 22, 2026
@renechoi @normanmaurer
POOL: Release Channel when SimpleChannelPool acquire is cancelled (#1…
6e7e69d
…7569)

`notifyConnect()` completes the acquire `Promise` with `trySuccess(...)`
and releases the `Channel` if already completed. `notifyHealthCheck()`,
the reuse path, still uses `setSuccess(...)`.

`doHealthCheck` runs via `loop.execute(...)` when `acquire()` is called
off its event loop, so a cancel can land while that task is queued, even
with the stock `ACTIVE` checker. `setSuccess(...)` then throws into
`closeAndFail(...)`: a healthy pooled `Channel` is closed and its
`channelAcquired(...)` gets no `channelReleased(...)`.

`notifyHealthCheck()` mirrors `notifyConnect()`, plus a regression test
on a hand-completed health check.

Reverting just the source hunk fails that test on `releasedCount()`, 2
expected, 1 seen. With it, 34/34.

(cherry picked from commit 6b257ce)
normanmaurer added a commit that referenced this pull request Sep 22, 2026
@netty-project-bot @renechoi @normanmaurer
Auto-port 4.1: POOL: Release Channel when SimpleChannelPool acquire i…
ec1de88
…s cancelled (#17578)

Auto-port of #17569 to 4.1
Cherry-picked commit: 6b257ce

---
### Motivation

`notifyConnect()` completes the acquire `Promise` with `trySuccess(...)`
and releases the `Channel` if already completed. `notifyHealthCheck()`,
the reuse path, still uses `setSuccess(...)`.

`doHealthCheck` runs via `loop.execute(...)` when `acquire()` is called
off its event loop, so a cancel can land while that task is queued, even
with the stock `ACTIVE` checker. `setSuccess(...)` then throws into
`closeAndFail(...)`: a healthy pooled `Channel` is closed and its
`channelAcquired(...)` gets no `channelReleased(...)`.

#17287 gave `FixedChannelPool` this guard.

### Modification

`notifyHealthCheck()` mirrors `notifyConnect()`, plus a regression test
on a hand-completed health check.

### Result

Reverting just the source hunk fails that test on `releasedCount()`, 2
expected, 1 seen. With it, 34/34.

---------

Co-authored-by: renechoi <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
@normanmaurer normanmaurer removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 16, 2026
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@netty-project-bot @renechoi
@normanmaurer @lltopk
Auto-port 4.1: POOL: Release Channel when SimpleChannelPool acquire i…
a8491fe
…s cancelled (netty#17578)

Auto-port of netty#17569 to 4.1
Cherry-picked commit: 6b257ce

---
### Motivation

`notifyConnect()` completes the acquire `Promise` with `trySuccess(...)`
and releases the `Channel` if already completed. `notifyHealthCheck()`,
the reuse path, still uses `setSuccess(...)`.

`doHealthCheck` runs via `loop.execute(...)` when `acquire()` is called
off its event loop, so a cancel can land while that task is queued, even
with the stock `ACTIVE` checker. `setSuccess(...)` then throws into
`closeAndFail(...)`: a healthy pooled `Channel` is closed and its
`channelAcquired(...)` gets no `channelReleased(...)`.

netty#17287 gave `FixedChannelPool` this guard.

### Modification

`notifyHealthCheck()` mirrors `notifyConnect()`, plus a regression test
on a hand-completed health check.

### Result

Reverting just the source hunk fails that test on `releasedCount()`, 2
expected, 1 seen. With it, 34/34.

---------

Co-authored-by: renechoi <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.19.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@renechoi @netty-project-bot @normanmaurer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.