-
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
"IllegalStateException: Invalid for read" after upgrading to 12.0.16 from 12.0.15 #12729
Comments
Can you tell us what frames are in the |
Oops, sorry. This is another example with all the Jetty and jakarta calls visible:
|
Thanks for that. I can see three filters, the last of which does a dispatch to the Servlet. thanks |
I don't think we are explicitly configuring any request wrapper. The call inmediately before is: |
@ofrias just to be clear, Also, can you provide details of your configuration, such as:
|
I don't know, we are using
We have not configured
This is our code in
cookies
No
|
Can you describe the scenario a little more? Is this a session that has previously been live on node 1, and is now being referenced for the first time on node 2? Or is this session likely to have been live on node 2 at some time in the past? If practicable, enabling debug logging for sessions may give us some more information to go on, set logging for the package |
@ofrias do you have any further info on this, such as the debug logs? Via code inspection I just can't see how you can have a reference to a non-resident session. The only time I've ever seen this is when application code keeps a reference to a session that was obtained from |
I rolled back to Jetty 12.0.15 two days ago and for the moment no occurrences of the issue, so this apparently confirms that it was introduced on version 12.0.16. It happens when I restart the 2 load balancer servers (for example to update their code). First I stop number 1, code is updated, then I start number 1 again, then I stop number 2, code is updated, and finally I start number 2 again. Since they are load balanced, I assume that sessions move between them. When one is stopped its sessions are moved to the other one, and then they come back to it once it starts again. It seems to me that this exception is fired on these session "migrations". We don't keep references to I have not generated logs yet. |
The sessions are sticky, yes? What algorithm is being employed for the balancing? |
Yes, sessions are sticky in the sense that they are processed by the same server if it is available. But when a server is shutdown they are processed by the other one, and when it comes back they are dispatched again to the original server. So they are moved two times between servers on a restart. |
Please find attached a sample log (sorry for the delay). This happened while shutting down a server. |
Thanks for that log, looks very useful. I'll have a closer look soon when I'm near a computer, but at first glance looks like an interaction between a newly created session that has not yet been persisted and the shutdown thread that tries to save all sessions before terminating. I don't recall any session code changing between 2.0.15 and 2.0.16, so it could just be the result of some timing differences due to code changes in other parts of jetty. BTW do you have saveOnCreate set to true for your session cache? |
No, we have not configured |
@ofrias I've got access to my computer again and checked the differences between 12.0.15 and 12.0.16 wrt the shutdown sequence, and I now know what is going on. We split out some of the handling of a graceful shutdown to a new module, called Prior to this change, we used to set the Please enable the new In the meanwhile, I will look at modifying the code so that a read on a session that has been shutdown is permitted (albeit with a log message, probably debug log). |
OK, I have enabled the |
Jetty version(s)
Jetty 12.0.16
Jetty Environment
ee10
Java version/vendor
(use: java -version)
openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)
OS type/version
Ubuntu Linux 24.04.1
Description
We have a setup with 2 load balanced Jetty instances. After upgrading from Jetty 12.0.15 to Jetty 12.0.16 we have started seeing these exceptions when we restart the servers and sessions have to move between Jetty instances:
How to reproduce?
It happens randomly when we restart Jetty instances, unfortunately we don't have a way to systematically reproduce it.
The text was updated successfully, but these errors were encountered: