-
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
Better resolve race between AsyncListener.onTimeout
and AsyncContext.dispatch
#6227
Comments
Only allow the thread calling onTimeout to call dispatch and complete once timeout has expired. Signed-off-by: Greg Wilkins <gregw@webtide.com>
I was able to reproduce this with a simple server and loadgenerator client setup.
Logs (partial DEBUG, full DEBUG doesn't trigger it for me) against 9.4.40 release - The QoSFilter$QoSAsyncListener.onTimeout starts the issue with this stacktrace ...
From there, the HttpChannelState.onTimeout creates more WARN messages. I'll try your branch next. |
squelch exception Signed-off-by: Greg Wilkins <gregw@webtide.com>
So is this patch ready? |
This has exposed a deficiency in the Servlet API/Spec. A new thread on the servlet-dev mailing list has been started about it ... |
@onintwo2 the patch for 9.4.x has been merged. If you can use 9.4.41-SNAPSHOT or build it yourself, you will be able to test it. |
Where is the link to see the changes made.
Dorion
From: Simone Bordet ***@***.***
Sent: Wednesday, May 05, 2021 12:08
To: eclipse/jetty.project
Cc: Dorion Carr; Mention
Subject: Re: [eclipse/jetty.project] Better resolve race between `AsyncListener.onTimeout` and `AsyncContext.dispatch` (#6227)
@onintwo2 <https://github.com/onintwo2> the patch for 9.4.x has been merged. If you can use 9.4.41-SNAPSHOT or build it yourself, you will be able to test it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#6227 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADYCGKSV54G2DQS24EI7UMTTMFUNPANCNFSM433MQNRA> .Image removed by sender.
|
Hi, We are using maven, can you publish the fix un a mvn repository? |
There is an intrinsic race between an application calling
AsyncContext.dispatch
and the container callingAsyncListener.onTimeout
.Currently when an async timeout expires, the
HttpChannelState
is atomically changed fromASYNC
toEXPIRE
, so that any subsequent call by the application toAsyncContext.dispatch
will receive an ISE.However, once the container starts calling any
AsyncListener.onTimeout
listeners, it switches the state toEXPIRING
as it is allowed for those listeners to callAsyncContext.dispatch
as part of their valid handling. However, at this point the current implementation is unable to distinguish between a valid call to dispatch from a listener vs a late call to dispatch from the normal application logic. So the dispatch is allowed, which can result in either the container throwing an ISE when is doesn't seeEXPIRING
state just before callingonTimeout
, or the handling within anonTimeout
listener may get an ISE as the request has already been dispatched.This results at least in a noisy logged exception. At worst, the application dispatch may be used even if onTimeout is called. Better handling would be that once EXPIRING, only the same thread is allowed to call
dispatch
(orcomplete for that matter
) so that only a listener will be able to call them and any late application calls are rejected with an ISE.Whilst this race has been seen in the wild, it will be very difficult to reproduce in a unit test as there is no suitable extension point.
The text was updated successfully, but these errors were encountered: