Skip to content

Avoid NoSuchElementException when an acquiring connection is closing#2110

Merged
pderop merged 2 commits intoreactor:1.0.xfrom
pderop:ensure-caller-eventloop-is-always-registered-when-subscribing-to-connection-pool
Apr 1, 2022
Merged

Avoid NoSuchElementException when an acquiring connection is closing#2110
pderop merged 2 commits intoreactor:1.0.xfrom
pderop:ensure-caller-eventloop-is-always-registered-when-subscribing-to-connection-pool

Conversation

@pderop
Copy link
Copy Markdown
Contributor

@pderop pderop commented Mar 18, 2022

The following PR attempts to avoid the following exception, which may happen when a connection is being acquired from the pool while the connection is concurrently closing:

java.util.NoSuchElementException: Context does not contain key: callereventloop
    at reactor.util.context.Context2.get(Context2.java:87)
    at reactor.netty.resources.DefaultPooledConnectionProvider$PooledConnectionAllocator.lambda$connectChannel$0(DefaultPooledConnectionProvider.java:498)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4400)
    at reactor.core.publisher.Mono.subscribeWith(Mono.java:4515)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4371)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4307)
    at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.drainLoop(SimpleDequePool.java:407)
    at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.pendingOffer(SimpleDequePool.java:558)
    at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.doAcquire(SimpleDequePool.java:268)
    at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.request(AbstractPool.java:432)
    at reactor.netty.resources.DefaultPooledConnectionProvider$DisposableAcquire.onSubscribe(DefaultPooledConnectionProvider.java:195)
    at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool$QueueBorrowerMono.subscribe(SimpleDequePool.java:676)
    at reactor.netty.resources.DefaultPooledConnectionProvider$DisposableAcquire.run(DefaultPooledConnectionProvider.java:223)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

The problem comes from #2029.
Fixes #2113

@pderop pderop added the type/bug A general bug label Mar 18, 2022
@pderop pderop added this to the 1.0.18 milestone Mar 18, 2022
@pderop pderop self-assigned this Mar 18, 2022
@pderop pderop requested a review from violetagg March 18, 2022 16:50
@violetagg
Copy link
Copy Markdown
Member

@pderop Do we have this issue for HTTP/2 or it is only for HTTP/1.1?

@pderop pderop requested a review from simonbasle March 31, 2022 11:02
@pderop
Copy link
Copy Markdown
Contributor Author

pderop commented Apr 1, 2022

thanks for the review @violetagg , @simonbasle

@pderop pderop merged commit 51eabd6 into reactor:1.0.x Apr 1, 2022
pderop added a commit that referenced this pull request Apr 1, 2022
@pderop pderop deleted the ensure-caller-eventloop-is-always-registered-when-subscribing-to-connection-pool branch April 1, 2022 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.util.NoSuchElementException: Context does not contain key: callereventloop

3 participants