Description
Jetty version(s)
9.4.44.v20210927
Java version/vendor (use: java -version)
Java 17
we use gcr.io/distroless/java17-debian11:nonroot
OS type/version
Debian 11
Description
We use Spring Boot 2.6.2 with Jetty.
In our logs the following log appears:
WARN [SpringApplicationShutdownHook] QueuedThreadPool: Stopped without executing or closing null
This seems to be the code that writes that warning log:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.44.v20210927/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java#L299
My understand is that either the BlockingQueue<Runnable> _jobs
contains objects that are null, or there is a race condition so that !_jobs.isEmpty()
is true
but then _jobs.poll()
returns null
because it is now empty.
I'm not sure if this issue could be related to Spring so I'd like to mention that we implemented a shutdown hook waiting for an ExecutorService:
@Configuration
public class MyConfig {
....
@Bean(destroyMethod = "onShutdown")
MyWorker createMyWorker() {
ExecutorService executorService = createExecutorService(); // returns a new ThreadPoolExecutor
return new MyBean(executorService);
}
}
public class MyWorker {
...
public boolean onShutdown() throws InterruptedException {
this.executorService.shutdown();
boolean terminatedGracefully = executorService.awaitTermination(180, TimeUnit.SECONDS);
return terminatedGracefully;
}
}
How to reproduce?
Unfortunately, I cannot reproduce it.
Activity
dzoech commentedon Oct 17, 2022
This issue is still occurring for us. Is there anything more I can do to help here?
joakime commentedon Oct 17, 2022
Wonder how a null job even entered the queue.
We have handling for
null
on_jobs.poll()
in other places in QTP, why not here?joakime commentedon Oct 17, 2022
Yeah, if you have a
QueuedThreadPool
, and you attempt to execute/offer a null job you'll get an exception.dzoech commentedon Oct 18, 2022
Would extending the if condition like this
be sufficient here? I can open a PR if you like.
joakime commentedon Oct 19, 2022
@gregw & @sbordet WDYT?
sbordet commentedon Nov 22, 2022
I think the loop should not test for
isEmpty()
, but just trying topoll()
until it seesnull
-- a job can be stolen while stopping.@dzoech care to submit a pull request?
dzoech commentedon Nov 24, 2022
Sure, I'll follow up with a PR in the next couple of weeks.
Issue jetty#7650 - Fix race condition when stopping QueuedThreadPool
Issue jetty#7650 - Fix race condition when stopping QueuedThreadPool
Issue jetty#7650 - Fix race condition when stopping QueuedThreadPool
Issue jetty#7650 - Fix race condition when stopping QueuedThreadPool
dzoech commentedon Feb 6, 2023
I now created the PR against 9.4 since we are using this version, which is predefined by
org.springframework.boot:spring-boot-dependencies:2.7.4
.Is this the correct approach to get it merged?
sbordet commentedon Feb 6, 2023
@dzoech please make the PR against branch
jetty-10.0.x
.Jetty 9.4.x is at End of Community Support, see #7958.
5 remaining items