Redisson Session Manager session attributes problem
See original GitHub issueWe want to use Redisson Session Manager as a Tomcat Session Manager. It is essential that Redisson is configured as a shared instance in Tomcat since plugins that need access to a shared Session will be used. We found a behavior that could potentially indicate a bug in the session management.
A simplified diagram of our system is shown in the following figure.
The repository with the test project based on Spring Boot is here: https://github.com/DJakosa/redisson-test
Expected behavior
All apps should use the same shared Session which is resolved based on JSESSIONID
cookie. The Session should contain attributes with latest values that also include session scoped beans.
Actual behavior
When the readMode
property of Manager configuration in context.xml
is set to REDIS
, behavior seems to be as expected (see value of session_attribute_count
in response or logs which is incremented by 1 for every request). But with REDIS
read mode, session scoped beans are not stored as session attributes.
However, if we change readMode to MEMORY
, session scoped beans are stored as session attributes. Behavior is as expected if requests are sent to apps with the same context path (app-a in Tomcat 1 and Tomcat 2). When the request is sent to a different app (e.g. to app-b after being sent to app-a before), the second app (app-b) gets session attributes with values of the last request to the first app (app-a). If the request is sent to the first app (app-a) again, the session attribute values such as session_attribute_count
will not continue from the values that the second app (app-b) had set. It also seems that session attributes that are added to the Session by the second app (such as session_attribute_app_b_value
) are not available in the first app.
Steps to reproduce or test case
- Checkout repository with the test project
- Build project with maven (
mvn clean verify
) to get war files at./app-a/target/app-a.war
and./app-b/target/app-b.war
- Run
docker-compose up
from project root to set up stack with two Tomcats and Redis - Send requests to following endpoints (use the same session identifier) and inspect response and logs:
- http://localhost:8090/app-a/session-values (app-a.war in Tomcat 1)
- http://localhost:8091/app-a/session-values (app-a.war in Tomcat 2)
- http://localhost:8091/app-a2/session-values (app-a.war in Tomcat 2 at context /app-a2)
- http://localhost:8091/app-b/session-values (app-b.war in Tomcat 2)
- Set different
readMode
property value (REDIS
orMEMORY
), redeploy docker stack, flush Redis and repeat step 4.
Redis version 5.0.7
Redisson version 3.11.6
Redisson configuration
See ./volume/conf/redisson.yaml
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:31 (18 by maintainers)
it works!
@alexbosy @DJakosa @luiszimmermann
I attached new version which fixes the issue. Could you give it a try?
redisson-tomcat-8-3.13.4-SNAPSHOT.jar.zip