question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redisson Session Manager session attributes problem

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
alexbosycommented, Aug 25, 2020

Here is update version. Please try it

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

it works!

1reaction
mrnikocommented, Aug 7, 2020

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis-Based Tomcat Session Management | Redisson
Redisson's Tomcat Session Manager allows you to store sessions of Apache Tomcat in Redis. It empowers you to distribute requests across a cluster...
Read more >
Tomcat non-sticky sessions with redisson - Stack Overflow
Solution: If redisson is not able to find session using current catalina managerBase then search for the session in redis itself and if...
Read more >
How to integrate Redis in Liferay for Tomcat's Session ...
Solution Based on Extending Redisson Session Manager · Ensure that the generated com.liferay.redis.redisson.integration.jar is placed in $TOMCAT_HOME/lib/ext.
Read more >
Redis-Based Tomcat Session Management - DZone
Redisson's Tomcat Session Manager allows you to store sessions of Apache Tomcat in Redis. It empowers you to distribute requests across a ...
Read more >
Apache Tomcat 9 (9.0.70) - Clustering/Session Replication ...
To get around these problem, you'll want to use the BackupManager . The BackupManager only replicates the session data to one backup node, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found