-
Notifications
You must be signed in to change notification settings - Fork 37
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
HazelcastSessionManager.findSession can return null for an existing session under load #42
Comments
Hi @gokhanoner, I've put together a basic test case able to reproduce the See: https://github.com/edwardsmatt/hazelcast-tomcat-sessionmanager-42-example After swapping the I have a fork with this fix applied, but I'm hesitant to open a PR until I understand the following in greater detail: My concerns are that I don't completely understand the ramifications of blindly changing those two lines (and also in the Do you think it might be simply a matter of updating the EntryListener along these lines: public void entryUpdated(EntryEvent<String, HazelcastSession> event) {
if (event.getMember() == null || !event.getMember().localMember()) {
sessions.put(event.getKey(), event.getMergingValue());
}
} I am working on testing this further to understand how it actually affects it, particularly with the merging of remote values and the safety and precedence of update operations (i.e. simply overwriting existing values which may result in race conditions). Any advice based on your understanding would be appreciated 👍 |
@edwardsmatt As you pointed out, the main with issue replacing |
Hi @gokhanoner, However, I can also verify that PR #41 fixes this issue as well. Have you had any chance to investigate a fix, if so are you able to provide an update to see if we can progress a fix? Thanks very much 👍 |
@edwardsmatt thank you for providing a detailed reproduce case. It helped a lot. I sent a PR for the fix of this issue, and tested it with your case. Please see #61. |
Hi, I've just tried using this fix (by compiling master locally) but it does not seem to fix it - I still get sessions not being found under high load. I think the fix does not lock enough, the sessionMap.get needs to be in a lock too:
with that in place I can simulate a high load and get no lost sessions |
@ghkarmseveer can you please provide a reproducer for your case? It would be really helpful for us to fix if any issues remain. Also, are the sticky sessions enabled in your case? |
Hi, I've shamelessly forked @edwardsmatt example and updated it to tomcat 8.5 . locally I get failures with the 1.1.4 release https://github.com/ghkarmseveer/hazelcast-tomcat-sessionmanager-42-example My patched branch doesn't get failures (but its not based on 1.1.4) No I'm not using sticky sessions |
@ghkarmseveer, in your example, you are trying to download
I run your test with using 1.1.4 and don't face any issues. Please let us know if you are still getting the failures. |
@alparslanavci sorry about the download link but still fails for me locally: |
I believe the issue is in this method: https://github.com/hazelcast/hazelcast-tomcat-sessionmanager/blob/master/tomcat8/src/main/java/com/hazelcast/session/HazelcastSessionManager.java#L226
from
findSession
methodAfter checking
sessionMap
, if the session is present, first remove & then set called. Afterremove
& beforeset
call, if you call the same method, you can getnull
fromsessionMap.get(id)
call. This could cause users getting null for an existing session under load, as described in #41The text was updated successfully, but these errors were encountered: