Memory Replication & Multi-threaded Concurrent Access to HttpSessions
By lwhite123 on Jun 11, 2009
Glassfish V2 Memory Replication
If you are using Memory Replication with GlassFish v2 and your web application involves multiple client threads concurrently accessing the same session id, then you may experience session loss even without any instance failure. The issue here is that our memory replication framework makes use of session versioning. This feature was designed with the more traditional http request/response communication pattern in mind.
For a number of types of applications however, this traditional pattern does not hold. Examples include many Ajax-related frameworks, the use of Frames, etc. Another example is when a page includes many static resources (e.g. jpg's). In these situations, most browsers will optimize the loading of these resources by using multiple parallel connections, each of which is handled by a separate request processing thread. If the application has already established a session then this too will involve more than one thread at a time accessing a single HttpSession.
We have provided a solution for these situations. Use the "relaxVersionSemantics" property in sun-web.xml - this allows the web container to return (for each requesting thread) whatever version of the session is in the active cache regardless of the version number. This is critical when multiple threads are interacting in an essentially non-deterministic fashion with the container.
Here is an example snippet from a sun-web.xml that demonstrates where to add this property: