-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Interrupt flag is not always cleared in between requests #7548
Comments
Example stack trace: https://gist.github.com/arhimondr/81d80f27722d5429bf5e210034660369 In I wonder if a single |
@arhimondr like you noticed, we reset the interrupted flag for every job we run. Jetty calls
That is not the case. |
It shouldn't be the case.
@sbordet Does anything change for non blocking (async) requests? It looks super weird. I will try to create a simple reproducer that I can share. |
Actually I'm able to reproduce the problem with something as simple as
When sending requests repeatedly (even with a simple single threaded loop) some of them return status |
Need more details on how you are using/deploying this servlet. Example: First time through on a REQUEST dispatch you hit |
@joakime Here is a different reproducer without
The reproducer is based on This class initializes the server: https://github.com/airlift/airlift/blob/master/http-server/src/main/java/io/airlift/http/server/HttpServer.java |
I think the problem is that we clear the interrupted flag in |
I'm wondering if we should also clear in HttpChannel.unhandle, as we can iterate over several calls to the application there ( eg error dispatch) and we should probably not prepared interrupt status.... or should we... as it is for the same request??? |
Driver methods such as Driver#updateSplitAssignment can be ran from a thread other than a thread created by TaskExecutor. Interrupting a thread that is not managed by the engine is potentially unsafe. For example the Jetty server may preserve the "interrupted" flag in between requests, potentially impacting a different task or a query: jetty/jetty.project#7548 While the issue in Jetty is likely a bug that will be fixed there is no real reason why to interrupt a method other than Driver#process (which is only invoked by the TaskExecutor). Other driver methods (such as Driver#updateSplitAssignment) are lightweight and shouldn't take any significant time to finish while the interrupt mechanism is rather intended to terminate a processing that could potentially take a significant amount of time.
Now clearing the interrupt flag. Signed-off-by: Simone Bordet <[email protected]>
Driver methods such as Driver#updateSplitAssignment can be ran from a thread other than a thread created by TaskExecutor. Interrupting a thread that is not managed by the engine is potentially unsafe. For example the Jetty server may preserve the "interrupted" flag in between requests, potentially impacting a different task or a query: jetty/jetty.project#7548 While the issue in Jetty is likely a bug that will be fixed there is no real reason why to interrupt a method other than Driver#process (which is only invoked by the TaskExecutor). Other driver methods (such as Driver#updateSplitAssignment) are lightweight and shouldn't take any significant time to finish while the interrupt mechanism is rather intended to terminate a processing that could potentially take a significant amount of time.
…s. (#7563) Now clearing the interrupt flag. Signed-off-by: Simone Bordet <[email protected]>
…s. (#7563) Now clearing the interrupt flag. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 7b648f6)
…s. (#7563) (#7773) Now clearing the interrupt flag. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 7b648f6)
Jetty version(s)
9.4.44.v20210927
Java version/vendor
(use: java -version)
OS type/version
Description
Sometimes when a thread processing a request is interrupted the "interrupted" flag is carried over to the next request handled by the same thread.
How to reproduce?
Request 1
Request 2
. WhenRequest 2
is processed by the same thread check if the current thread is interrupted.Unfortunately the issue doesn't reproduce all the time.
The text was updated successfully, but these errors were encountered: