Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jersey threads can attempt to write after Netty's event loops are shut down #2499

Closed
spericas opened this issue Nov 4, 2020 · 3 comments
Closed
Assignees
Labels
jax-rs JAX-RS and Jersey related issues webserver
Milestone

Comments

@spericas
Copy link
Member

spericas commented Nov 4, 2020

Under heavy load and when Jersey threads are blocked on I/O, it appears these threads can attempt to write to a connection after the Netty's event loops are shut down, resulting in a RejectedExecutionException thrown by Netty. As a result, an application may report multiple exceptions while shutting down.

@spericas spericas added webserver jax-rs JAX-RS and Jersey related issues labels Nov 4, 2020
@spericas spericas added this to the 2.1.1 milestone Nov 4, 2020
@spericas spericas self-assigned this Nov 4, 2020
@spericas
Copy link
Member Author

spericas commented Nov 4, 2020

Details of exception that can be reported multiple times:

helidon-mp: java.util.concurrent.RejectedExecutionException: event executor terminated
helidon-mp: 	at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:926)
helidon-mp: 	at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:353)
helidon-mp: 	at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:346)
helidon-mp: 	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:828)
helidon-mp: 	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:818)
helidon-mp: 	at io.netty.util.concurrent.DefaultPromise.safeExecute(DefaultPromise.java:841)
helidon-mp: 	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
helidon-mp: 	at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:183)
helidon-mp: 	at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:95)
helidon-mp: 	at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:30)
helidon-mp: 	at io.helidon.webserver.BareResponseImpl.writeLastContent(BareResponseImpl.java:281)
helidon-mp: 	at io.helidon.webserver.BareResponseImpl.completeInternal(BareResponseImpl.java:221)
helidon-mp: 	at io.helidon.webserver.BareResponseImpl.onComplete(BareResponseImpl.java:396)
helidon-mp: 	at io.helidon.media.common.MessageBodyContext$EventingSubscriber.onComplete(MessageBodyContext.java:354)
helidon-mp: 	at io.helidon.common.reactive.MultiMapperPublisher$MapperSubscriber.onComplete(MultiMapperPublisher.java:98)
helidon-mp: 	at io.helidon.common.reactive.EmittingPublisher.signalOnComplete(EmittingPublisher.java:183)
helidon-mp: 	at java.base/java.util.concurrent.CompletableFuture.uniRunNow(CompletableFuture.java:815)
helidon-mp: 	at java.base/java.util.concurrent.CompletableFuture.uniRunStage(CompletableFuture.java:799)
helidon-mp: 	at java.base/java.util.concurrent.CompletableFuture.thenRun(CompletableFuture.java:2185)
helidon-mp: 	at io.helidon.common.reactive.EmittingPublisher.complete(EmittingPublisher.java:146)
helidon-mp: 	at io.helidon.common.reactive.MultiFromOutputStream.complete(MultiFromOutputStream.java:201)
helidon-mp: 	at io.helidon.common.reactive.MultiFromOutputStream.close(MultiFromOutputStream.java:129)
helidon-mp: 	at io.helidon.webserver.jersey.ResponseWriter$1.close(ResponseWriter.java:79)
helidon-mp: 	at io.helidon.webserver.jersey.ResponseWriter.commit(ResponseWriter.java:161)
helidon-mp: 	at org.glassfish.jersey.server.ContainerResponse.close(ContainerResponse.java:390)
helidon-mp: 	at org.glassfish.jersey.server.ServerRuntime$Responder.release(ServerRuntime.java:736)
helidon-mp: 	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:442)
helidon-mp: 	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
helidon-mp: 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
helidon-mp: 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
helidon-mp: 	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
helidon-mp: 	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
helidon-mp: 	at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
helidon-mp: 	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
helidon-mp: 	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232)
helidon-mp: 	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
helidon-mp: 	at io.helidon.webserver.jersey.JerseySupport$JerseyHandler.lambda$doAccept$3(JerseySupport.java:283)
helidon-mp: 	at io.helidon.common.context.Contexts.runInContext(Contexts.java:98)
helidon-mp: 	at io.helidon.common.context.ContextAwareExecutorImpl.lambda$wrap$1(ContextAwareExecutorImpl.java:129)
helidon-mp: 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
helidon-mp: 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
helidon-mp: 	at java.base/java.lang.Thread.run(Thread.java:832)```

@spericas
Copy link
Member Author

spericas commented Nov 4, 2020

The scenario here is a Docker container that is stopped via a SIGTERM followed by a SIGKILL. Perhaps the SIGTERM is causing the event loop to shut down while the Jersey threads are still running --which may explain why they attempt and fail to write data to a connection. More investigation is needed.

@spericas
Copy link
Member Author

spericas commented Nov 5, 2020

PR #2505

@m0mus m0mus modified the milestones: 2.1.1, 2.2.0 Nov 12, 2020
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jax-rs JAX-RS and Jersey related issues webserver
Projects
Archived in project
Development

No branches or pull requests

2 participants