-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Deadlock between SseEmitter and StandardServletAsyncWebRequest when clients disconnect #33421
Comments
Thank you for the investigation. This looks like a valid issue. |
I pushed a fix 3d1bf28, but I was not able to reproduce the condition with the demo. Possibly related, after the index page loads, this appears in the logs:
If you could give it a try with |
I tried with 6.1.13-SNAPSHOT and can not reproduce anymore with the demo (and reloading quickly many times in a row) Still, there's this scary warning in the logs:
|
Thanks for the feedback and by the way 6.1.13 was released in the mean time. For the new stacktrace, I have looked at the source code and cannot understand why or how this can happen. On the original stacktrace, the "task-4" thread is on line 332 of In order for the dispatch on line 411 of For the I will try the example again to see if I have better luck, but it would help to see a full stacktrace for the exception. You could try DEBUG level logging for org.springframework.web, or an |
Below the full stacktrace (with 6.6.13, a similar one was also reproduced with 6.6.12 - so, this is not something new):
|
Is this something that should be backported to 5.3.x or does it affect only higher versions? |
@micvm older generations are only commercially supported at this point, see https://spring.io/projects/spring-framework#support |
Oh thanks. I totally missed that deadline. That's why there is no backport then. |
We announced this on our blog and since released a first set of commercial versions for a CVE fix. You can learn more about our support offering here: https://spring.io/support |
We have been tracking rather strange & random failures in our application: eventually, after many browser closed (and/or page refresh), our SSE event flux would not be sending anything anymore to new clients.
We identified that threads used for async tasks execution (AsyncSupportConfigurer) may deadlock due to a timing-dependant ABBA deadlock between SseEmitter sending and error handling on connection closed.
If using the the default SimpleAsyncTaskExecutor which fires up a new Thread for each task, no user visible effect (except that some deadlocked unused threads are consumming resources on the server).
But, if using a fixed number of threads (as we do in our application), the system may finally come to a halt (when all worker threads have been deadlocked).
What we think is going on (see example jstack trace captured):
So, we think that there's a potential ABBA deadlock between SSE error handling and concurrent SSE sending.
Things are highly timing dependent, but we have been able to reproduce (with high probablity) our observed deadlocks:
the idea is to emit big JSON objects (increasing the concurrency window) and normal objects concurrenty on the flux, while closing the browser
Reproduced with spring boot 3.3.2 (springframework 6.1.11) and also 3.3.3 (springframework 6.1.12)
Steps to reproduce:
See the minimalist example attached, with the following steps to reproduce:
Example of deadlock captured using jstack:
demodeadlock.zip
The text was updated successfully, but these errors were encountered: