redisson: Redisson Session Manager session attributes problem

We 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.

download

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

  1. Checkout repository with the test project
  2. 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
  3. Run docker-compose up from project root to set up stack with two Tomcats and Redis
  4. Send requests to following endpoints (use the same session identifier) and inspect response and logs:
  5. Set different readMode property value (REDIS or MEMORY), 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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 31 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Here is update version. Please try it

redisson-tomcat-8-3.13.4-SNAPSHOT.jar.zip

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

@luiszimmermann

session scoped beans should be used with @EnableRedissonHttpSession annotation. Did you set it?

Right now I am only using the redisson in tomcat, following this strategy, without putting any redisson dependency in my app (grails 2.5.6/spring 4.2.9).

Should I add the redisson in my app and create the Configuration files with EnableRedissonHttpSession to make the readMode="REDIS" works with mutable session?

Confirmed in my tests.

  1. Tomcat A 9.0.36 with Redisson 3.12.5
  2. Tomcat B 9.0.36 with Redisson 3.12.5
  3. Redis 5.0.9 with 3 sentinels, 2 nodes

context.xml with <Manager className="org.redisson.tomcat.RedissonSessionManager" configPath="${catalina.base}/conf/redisson.yaml" broadcastSessionEvents="true" readMode="REDIS" updateMode="DEFAULT" />

With readMode="MEMORY" the flash messages session attributes works as expected.